How to do this part correctly?
// Start How do I do this part correction?

                                        EditText ppString = (EditText)
layout1.findViewById(R.id.p_string);
                                        ppString.setText(pString);

// End How do I do this part correction?

I try to put in handler -> runInUIThread seems that I cannot declare
layout1.findViewById(R.id.p_string), if I use only
findViewById(R.id.p_string) I can run but crash.

What I want to do is to have user input a form display as dialog
format, pressing a button will start a child dialog (dialog2)
accepting some radio button to generate a String result to update and
display a EditText field in Dialog1.

Is this possible? How do I do it?

---code---
        @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
                case ADD_DIALOG_ID:
                LayoutInflater inflater1 = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                final View layout1 =
inflater1.inflate(R.layout.add_pwd, (ViewGroup)
findViewById(R.id.content0));
                final AlertDialog.Builder builder1 = new
AlertDialog.Builder(this);

                final Button genButton = (Button)
layout1.findViewById(R.id.genpass_button);

                genButton.setOnClickListener(new
Button.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                        showDialog(GEN_DIALOG_ID);

// Start How do I do this part correction?

                                        EditText ppString = (EditText)
layout1.findViewById(R.id.p_string);
                                        ppString.setText(pString);

// End How do I do this part correction?

                                }
                        });

                builder1.setView(layout1);
                // Now configure the AlertDialog
                builder1.setTitle(R.string.app_name);
                AlertDialog newPDialog = builder1.create();
                return newPDialog;

                case GEN_DIALOG_ID:
                        Main.this.removeDialog(ADD_DIALOG_ID);
                LayoutInflater inflater2 = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                final View layout2 =
inflater2.inflate(R.layout.generate_pwd, (ViewGroup)
findViewById(R.id.generate_pwd));
                final AlertDialog.Builder builder2 = new
AlertDialog.Builder(this);

                RadioGroup radioGroup = (RadioGroup)
layout2.findViewById(R.id.password_type);
                radioGroup.setOnCheckedChangeListener(new
OnCheckedChangeListener()
                {
                                @Override
                    public void onCheckedChanged(RadioGroup group, int
checkedId) {
                        //---displays the ID of the RadioButton that
is checked---
                        switch (checkedId) {
                        case R.id.this:
                            ToastBox("Lowercase");
                            Type = "-l";
                                break;
                        case R.id.that:
                            ToastBox("Uppercase");
                            passwordType = "-u";
                                break;
                        }
                    }
                });

                builder2.setView(layout2);
                // Now configure the AlertDialog
                builder2.setTitle(R.string.sword_type);

                builder2.setPositiveButton(android.R.string.ok, new
DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int
whichButton) {
                        try {
                                final EditText pLength = (EditText)
layout2.findViewById(R.id.p_length);
                                ppLength =
Integer.parseInt(pLength.getText().toString());
                                                        pString = 
PGenerator.GetRandomP(pType, pLength);
                                                } catch (Exception e) {
                                                        // TODO Auto-generated 
catch block
                                                        e.printStackTrace();
                                                }
                                                
Main.this.removeDialog(GEN_DIALOG_ID);
                                                showDialog(ADD_DIALOG_ID);
                        }
                });

                builder2.setNegativeButton(android.R.string.cancel, new
DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int
whichButton) {
                                // We forcefully dismiss and remove the Dialog, 
so it
                                // cannot be used again (no cached info)
                                Main.this.removeDialog(GENPASSWORD_DIALOG_ID);
                        }
                });

                AlertDialog genPasswordDialog = builder2.create();
                return genPasswordDialog;
        }
                return null;
        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to