在按钮事件中我应该使用AlertDialog.builder的上下文?

时间:2010-12-23 10:03:22

标签: android android-context

我正在使用此代码...请纠正它

btnLogin.setOnClickListener(new OnClickListener() 
        {
        @Override
        public void onClick(View v)  
        {
         // Check Login
         String username = etUsername.getText().toString();
         String password = etPassword.getText().toString();

          String str1 = DownloadText("http://........");
          if(str1.length()==1)
          {

          AlertDialog dialog = new AlertDialog.Builder(btnLogin).setTitle("Alert 1").setMessage("Login Success").create();
           alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                             public void onClick(DialogInterface dialog, int which) {
                                     return;
                             }});
}}

1 个答案:

答案 0 :(得分:1)

....新的AlertDialog.Builder( YourActivity.this )......