Android listview item not getting focus -
Android listview item not getting focus -
my item in listview not getting focus, onfocuschanged not working created log statement log focus , returning "false" result of v.isfocused().
the onclick method working fine.
any ideas?
@override public view getview(final int position, view convertview, viewgroup parent) { view row = convertview; final exerciselistholder holder; if (row == null) { layoutinflater inflater = ((activity) context).getlayoutinflater(); row = inflater.inflate(layoutresourceid, parent, false); holder = new exerciselistholder(); holder.textview = (textview) row.findviewbyid(r.id.exercise_list_text_view); holder.imageview = (imageview) row.findviewbyid(r.id.trash_button); holder.edittext = (edittext) row.findviewbyid(r.id.exercise_list_edit_text_view); holder.deletebutton = (button) row.findviewbyid(r.id.delete_button); row.settag(holder); } else { holder = (exerciselistholder) row.gettag(); } final exercise exercise = data.get(position); holder.textview.settext(exercise.getname()); holder.imageview.setvisibility(view.gone); holder.edittext.setvisibility(view.gone); holder.deletebutton.setvisibility(view.gone); holder.imageview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { holder.imageview.setvisibility(view.gone); holder.deletebutton.setvisibility(view.visible); holder.deletebutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { database db = new database(context); db.deleteexercise(exercise); notifydatasetchanged(); } }); } }); row.setfocusable(true); row.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { v.requestfocus(); log.d("focused?", boolean.tostring(v.isfocusable())); log.d("focused?", boolean.tostring(v.isfocused())); exerciselistholder holder = (exerciselistholder) v.gettag(); holder.edittext.settext(holder.textview.gettext()); holder.edittext.setselection(holder.edittext.gettext().length()); holder.imageview.setvisibility(view.visible); holder.textview.setvisibility(view.gone); holder.edittext.setvisibility(view.visible); } }); homecoming row; }
maybe adding listview android:descendantfocusability="afterdescendants", help you. more in docs.: here
android listview
Comments
Post a Comment