1

I have a ListView in which I have a EditText in each item of the list.

When I click on the EditText and scroll the ListView the focus of the EditText moves to some other item's EditText.

Why is this happening and could someone help in stopping this from happening?

Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
Sunny
  • 7,444
  • 22
  • 63
  • 104

1 Answers1

3

Add the else part to your convertView code inside getView method.

if(convertView==null){
    LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
    convertView = inflater.inflate(R.layout.layout, null);
    holder = new ViewHolder(convertView);
    convertView.setTag(holder);
}else{
    holder = (ViewHolder) convertView.getTag();
    if (((ListView)parent).getSelectedItemPosition() == ListView.INVALID_POSITION) {
        parent.requestFocus();
    }
}

A similar query is here.

Community
  • 1
  • 1
Atul O Holic
  • 6,692
  • 4
  • 39
  • 74