android - Listview - has focus always return false -
i have edit text in list view. listview created using base adapter , used holders load edit text.
when cal holder.edttext.hasfocus(), return false. missing in listview properties?
public view getview(final int position, view convertview, final viewgroup parent) {
if (convertview == null) {
layoutinflater inflater = layoutinflater.from(getcontext());
convertview = inflater.inflate(r.layout.screen, parent, false);
holder = new adapter.viewholder(convertview);
convertview.settag(holder);
} else {
holder = (adapter.viewholder) convertview.gettag();
}
holder.edt.setcursorvisible(holder.edt.hasfocus());
holder.edt.setenabled(true);
holder.edt.settag(r.string.view, “some object”);
if (position == 10) {
holder.edt.requestfocus();
}
holder.edt.setfilters(new filter());
holder.edt.addtextchangedlistener(new watcher());
holder.edt.settext(“text”);
holder.edt.setselection(text.length);
holder.edt.setselectallonfocus(true);
return convertview;
} public class viewholder extends recyclerview.viewholder {
public edittext edit;
public viewholder(view itemview) {
super(itemview);
edt = (edittext) itemview.findviewbyid(r.id.edt);
}
}
try adding
android:descendantfocusability="afterdescendants"
to listview
Comments
Post a Comment