Thursday, April 4, 2013

EditText inside alertdialog


Having this class code to create a dialog :



public class DConce extends DialogFragment{

public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder dshow = new AlertDialog.Builder(getActivity());

LayoutInflater inflater = getActivity().getLayoutInflater();

dshow.setView(inflater.inflate(R.layout.dialogconc, null))

.setPositiveButton("Send", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {

//TODO


}
})
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
DConce.this.getDialog().cancel();
}
});

return dshow.create();

}

public static DConce newInstance(){
DConce arg = new DConce();
return arg;
}


I am trying to get some data from user input with a EditText. The object is created on the xml. I am trying to call it with



EditText dlgText = (EditText) Dconce.findViewById(R.id.txconc);


But it just will not find findViewByid on the dialog. Isn´t the view included here? dshow.setView(inflater.inflate(R.layout.dialogconc, null))


Any help please? Thanks in advance.


PS: The dialog is created just fine and I can see the EditText. I just cannot work with it.



.

forum.xda-developers.com

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...