Skip to content Skip to sidebar Skip to footer

Settext To Edittextbox From Dialog Content?

Am using customDialog which i was customized to show list.my Requirement is Where ever having Edittext in my application.i need to show this dialog.am using Textwatcher in editext

Solution 1:

Simply you can pass your EditText object to this method and inside the OnitemClickListener you can set text to the EditText using the values from your Arraylist.

publicstaticvoidamount_dialog(final Activity activity,String str,EditText edittextObject)
{
     amount=str;

     sequence_number();//from this method am generating list and setting it into my Arraylist

     dialog=newDialog(activity,R.style.CustomDialogTheme);    

     dialog.setContentView(R.layout.customdialog);

     ListView listView=(ListView) dialog.findViewById(R.id.listView12);              
     adapter=newArrayAdapter<String>(activity,R.layout.list2,R.id.list_text1, strings);
     listView.setAdapter(adapter);  
     listView.setOnItemClickListener(newAdapterView.OnItemClickListener() {

        @OverridepublicvoidonItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            selected_amount=adapter.getItem(arg2);
             edittextObject.setText("get the value from arraylist here");
            dialog.dismiss();


        }
    });


     dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;

     dialog.show();
     dialog.setCanceledOnTouchOutside(true);


}

Solution 2:

I assume that the activity you pass as a parameter is the activity containing your EditText. So you can do something like this:

EditTexteditText= (EditText)activity.findViewById(theIDofYourTextEdit);
editText.setText(selectedAmount);

inside your onItemClick-method.

I hope this helps

Post a Comment for "Settext To Edittextbox From Dialog Content?"