由网友(◇咒鬼)分享简介:我试图开发一种显示警告用户,不会让去任何地方弹出消息框(甚至不许走在主屏幕/菜单)。I am trying to develop popup message box which shows warning to user and won't allow to go anywhere (even not allowed...
我试图开发一种显示警告用户,不会让去任何地方弹出消息框(甚至不许走在主屏幕/菜单)。
I am trying to develop popup message box which shows warning to user and won't allow to go anywhere (even not allowed to go at home screen/menu).
我试图把按钮就可以了,直到我preSS该按钮,写用户名和密码,使用户不能去任何地方。
I'm trying to put button on it until I press on that button and write username and password, so that user can't go any where.
我应该中断或直接拨打到另一个活动?因为我想在1日的活动在完成任务后,要做到这一点上面的事,我想上面做旁边ativity流行的事情。
Should I interrupt or simply call to another activity? As I want to do this above thing after completing task on 1st activity, And I want do above pop thing on next ativity.
推荐答案
有关创建弹出像创建一个方法:
Create a method for creating that popup like :
public void showAlert() {
/* Layout that is shown inside the alert */
LayoutInflater factory = LayoutInflater.from(mContext);
//create a layout that is shown inside ur popup and give its name over here
final View calibrateView = factory.inflate(your layout, null);
EditText username = (EditText)calibrateView.findViewById(R.id.username);
EditText password = (EditText)calibrateView.findViewById(R.id.password);
/* Creating the popup */
AlertDialog.Builder alert = new AlertDialog.Builder(mContext);
alert.setView(calibrateView);
alert.setTitle(your title);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//check whether username and password is present over here.
//if present give ur intent code for moving to the next activity
//if absent, then create an alert showing the error msg
}
});
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
/* called when AlertDialog "Cancel" button is pressed. */
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.create();
alert.show();
}
相关推荐
最新文章