i created simple preference class shows autocompletetextview control , displays when focus on autocompletetextview , start typing brings keyboard loses focus on control.
any idea why loses focus?
here's did create view. inflated layout basic linear layout title textview in it.
i change dialog preference instead guess it'd smoother if part of base view.
@override protected view oncreateview(viewgroup parent) { layoutinflater inflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service); linearlayout layout = (linearlayout) inflater.inflate(r.layout.base_preference, null); if (mhint != null) { textview hintview = (textview) layout.findviewbyid(r.id.preferencehinttextview); hintview.settext(mhint); } textview titleview = (textview) layout.findviewbyid(r.id.preferencetitletextview); titleview.settext(gettitle()); autocompletetextview inputview = new autocompletetextview(getcontext()); inputview.setgravity(gravity.fill_horizontal); arrayadapter<charsequence> adapter = new arrayadapter<charsequence>(getcontext(), r.layout.auto_complete_text_list_item, getentries()); inputview.setadapter(adapter); inputview.setthreshold(1); inputview.setonitemselectedlistener(this); layout.addview(inputview); return layout; }
the list item is:
<?xml version="1.0" encoding="utf-8"?> <textview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textsize="16sp" android:textcolor="#000"> </textview>
could've been standard list item , come out identical.
i spent bit of time trying re-create issue you:
couple of questions:
- what getcontext() / getting context from?
- can show r.layout.auto_complete_text_list_item? standard list item worked me
- can show getentries() method? after testing small string[] array, worked me.
- setonitemselectedlistener(this) - can show method you're using implements onitemselectedlistener - might need requestfocus() here or doing odd pull focus away control... although selected , not click. i'm not sure if firing auto-select list (i.e. defaulting first item
lastly, try setting component xml , not doing dynamically test. first factor tried control. know you'll want dynamic it's not bad thing create custom autocompletetextview control uses own layout.
hope these help! project me review , assist.
Comments
Post a Comment