2011-03-08 11 views
0

私はユーザーに警告を表示し、どこに行くことを許可しませんポップアップメッセージボックスを開発しようとしています(ホーム画面/メニューに行くこともできません)。Android_Alertメッセージ_Whichは閉じません

私はそのボタンを押してユーザー名とパスワードを書いてからユーザーがどこにも行くことができないようにするまで、ボタンを置いています。

他のアクティビティを中断するか、単に呼び出す必要がありますか? 1回目の活動を終えた後にこれをやりたいのですから、次の活動で上手くやりたいです。

+0

を。 –

答えて

1

のようにそのポップアップを作成するための方法で作成します。重複した質問を投稿する停止してください

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(); 
    } 
関連する問題