android: navigation issue in ListView without touch ui on google DTV -
i working on custom listview activity this
public class mainactivity extends activity { listview listview = null; int position = 0; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listview = (listview)findviewbyid(r.id.list); string[] values = new string[] { "android list view", "adapter implementation", "simple list view in android", "create list view android", "android example", "list view source code", "list view array adapter", "android example list view" }; madapter = new mylistadapter(this, r.layout.list_item, new arraylist<string>(arrays.aslist(values))); listview.setadapter(madapter); listview.setonitemselectedlistener(mitemlistener); } private adapterview.onitemselectedlistener mitemlistener = new adapterview.onitemselectedlistener() { @override public void onitemselected(adapterview<?> arg0, view arg1, int position1, long arg3) { madapter.setselection(position1); } @override public void onnothingselected(adapterview<?> arg0) { } }; }
and list adapter getview is
@override public view getview(int position, view convertview, viewgroup parent) { string result = msearchresultlist.get(position); viewholder holder = null; if (convertview == null) { holder = new viewholder(); layoutinflater inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); convertview = inflater.inflate(mresourceid, parent, false); holder.mtextview1 = (textview)convertview.findviewbyid(r.id.list_text1); holder.mtextview2 = (textview)convertview.findviewbyid(r.id.list_text2); convertview.settag(holder); }else { holder = (viewholder) convertview.gettag(); } if (mselected == position) { holder.mtextview1.setbackgroundresource(r.drawable.epg_genre_btn_focus); }else { holder.mtextview1.setbackground(null); } holder.mtextview1.settext(result) ; holder.mtextview2.settext(result) ; return convertview; } int mselected =0; void setselection(int pos){ mselected = pos; notifydatasetchanged(); }
i not working on touch ui on google dtv without touch events. using dpad navigation. every thing working fine until reaching lastvisible position in list. when selected item lastvisible position , press downkey in dpad highlighed(bacground item) first scroll 1 position goes down lastvisible position. please me on have tried many permutation , combination not able solve problem
Comments
Post a Comment