Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText On A Popup Window

I am developing on Android 2.2 using Java. I put an editText on a PopupWindow and it's not working. It acts like a disabled edit text, clicking on the edit text won't show the soft keyboard. How can I add an edit text on a popupWindow?

like image 531
Laura Avatar asked Nov 09 '10 13:11

Laura


2 Answers

Just try:

AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setTitle("Title");
alert.setMessage("Message");

// Set an EditText view to get user input 
final EditText input = new EditText(this);
alert.setView(input);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

  // Do something with value!
  }
});

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int whichButton) {
    // Canceled.
  }
});

alert.show();
like image 82
Siten Avatar answered Nov 10 '22 16:11

Siten


I have resolved the problem like this: I put the popupWindow.setFocusable(true); and now it's working. It seems that the edit text which was on a pop window didn't have focus because the popup window didn't have focus.

like image 37
Laura Avatar answered Nov 10 '22 16:11

Laura