开发者

using buttons and textedit

Hi all iam new to android can anybody help me. i have a total of 30 buttons if i click each button i should get开发者_JAVA百科 a edit dialog with OK button where i will type some name and click OK button then that name should go and sit on that clicked button can anybody suggest how to go about it. Thanks in advance


onClick of the buttons do like dis..

    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setMessage("Enter your email id..");
    alert.setTitle("Forgot Password..");
    final EditText text = new EditText(this);
    text.setInputType(InputType.TYPE_CLASS_TEXT);
    alert.setView(text);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int arg1) {
            // TODO Auto-generated method stub
            dialog.dismiss();
            if(text.getText().toString().trim().equalsIgnoreCase("")) {
                ShowAlert("You haven't enter any password..");
            }
            else {
                inputXmlGenerator = new InputXmlGenerator();
                forgot_pswrd_req = inputXmlGenerator.createForgotPasswordRequestXml(text.getText().toString());
                conn = new Connection(url, forgot_pswrd_req, "ForgotPassword");
                conn.connect();
            }
        }
    })
    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {


        public void onClick(DialogInterface dialog, int arg1) {
            // TODO Auto-generated method stub
            dialog.dismiss();
        }

    });
    alert.show();

You can put it in a method and set a parameter which guide you to do that task , you like to do after clicking the OK button. Here i put a cancel button. You can keep it or can remove it.

This is the basic thing you need to do. Now do it in your way you like to do.

try it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜