Android EditText in ListView – keyboard-ThrowExceptions

Exception or error:

I’ve got a problem with my EditText. I use the following adapter:

public class RowTextViewAdapter extends BaseAdapter {


  public View getView(int position, View convertView, ViewGroup parent) {

  ViewHolder holder = null;

    if (rowTitles.get(position).equals("edit")) {
        if(et == null){
            et = new EditText(activity);
        return et;
    else {
        convertView = new TextRow(activity);
        holder = new ViewHolder(((TextRow) convertView).getTextView(), ((TextRow) convertView).getImageView());
        holder.getTextView().setText(StringManager.getInstance().getText(rowTitles.get(position), activity));
        holder.getImageView().setImageBitmap(assetController.getBitmap(additiveIcons.get(position) + ".png", null));
        return convertView;

and ListActivity:

public class AppSettingActivity extends ListActivity {

    public void onCreate(Bundle savedInstanceState) {

        adapter = new RowTextViewAdapter(this);
        adapter.addRowView("account", "arrowDw");
        adapter.addRowView("password", "arrowDw");


   protected void onListItemClick(ListView listView, View view, int position, long id) {
    switch (position) {
        case 0: accIsEditable = adapter.setEditable(position); break;
        case 1: 
            if(accIsEditable) {
                                    //TODO do something..
            pwIsEditable = adapter.setEditable(position);

If i click on the first item I add a new list item on pos. 1 (pos: 0, 1, 2, …).
Now the EditText field is added to the list.

----------------------------          -------------------------    
Account                   v           Account                ^     
----------------------------    ==>   -------------------------     
Passowrd                  v           [::::::::EditText:::::::]      
----------------------------          -------------------------
//more..                              Password               v
----------------------------          -------------------------

If I click now into the EditText field, it shows the virtual keyboard and loses focus of the EditText. I click again and it gains focus. But if I write something, the text is only showed in the EditText field, if i tap on it and not frequently while i’m writing…

Any idea to fix that update problem?

How to solve:

If this is still an issue, take a look at this item: Focusable EditText inside ListView

This changes may help.

Change to listview:


Change to activity in mainfest.xml:

<activity android:name= ".yourActivity" android:windowSoftInputMode="adjustPan"/>


some times when you use android:windowSoftInputMode="stateAlwaysHidden"in manifest activity or xml, that time it will lose keyboard focus. So first check for that property in your xml and manifest,if it is there just remove it. After add these option to manifest file in side activity android:windowSoftInputMode="adjustPan"and add this property to listview in xml android:descendantFocusability="beforeDescendants"

Leave a Reply

Your email address will not be published. Required fields are marked *