2013年9月22日星期日

android listview item STB development focus ! Seeking large cow !

I want this effect

listview item has textview and imageButton, imageButton are hidden by default , and when I press the arrow keys when , item background to change, and choose to which item, item in the imagebutton will show up , imagebutton alone can respond to events . The item did not focus becomes the default background , which will hide the imagebutton .
indicate the problem has been plagued by one week the
------ Solution ---------------------------- ----------------
ListView xml file attributes add "
android: descendantFocusability = "blocksDescendants" "

in listview find getview method to determine access point or not, there will visible , there is no respect for the "gone"
------ Solution ------------ --------------------------------
Bangding ! lz problem solved it ? With demand !
------ Solution ---------------------------------------- ----

yes, Button controls that can receive focus . . CheckBox same. .
------ eference --------------------------------------- < br> My item has three imagebutton, each button has a different event , that imagebutton to be able to get to the point , the three can click on each .
android: descendantFocusability = "blocksDescendants" item , then add this property to get inside the imagebutton not focus it.
------ eference --------------------------------------- < br> top
------ eference - --------------------------------------
sink ?
------ eference - --------------------------------------
OnItemSelectedListener useless, there is BUG ; , when each switch once Item , Item background will flash and disappear when the Activity when the focus will go to the first one to add incoming control has focus , that whenever the switch once Item, focus lost - > Focus jump outside the ListView control - > Focus and then jump back to the next Item.
But the problem has been resolved , I used TableLayout instead of ListView implementation, there will be no such BUG
------ eference --------- ------------------------------
listview focus of a good solution , you have to first get your child focus , acquisition method android: descendantFocusability = "beforeDescendants", so that you can get every child to focus , listview achieve setOnItemSelectedListener then implement the following code in the callback where you can ,
public void onItemSelected (AdapterView parent, View view, int position, long id) {
mListView.clearFocus ();
ViewGroup viewGroup = (ViewGroup) view;
viewGroup.setDescendantFocusability (ViewGroup.FOCUS_BEFORE_DESCENDANTS);
viewGroup.requestFocus ();
}
Perhaps there is a better implementation.

没有评论:

发表评论