Hi I have a list. I can set the back ground color , press color, and fosusing color in listbg.xml (selector). However the focus color doesn't work at all. The list item never get focus. Do I need to wrote code for focus?
My code: listbg.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/ list_focus"/> <item android:state_focused="true" android:drawable="@drawable/ err_color"/> <item android:state_enabled="true" android:drawable="@drawable/ list_bg"/> <item android:state_selected="true" android:drawable="@drawable/ err_color"/> <item android:drawable="@drawable/list_bg" /> </selector> listItem.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="8dip" android:background="@drawable/listbg"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/error" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/toptext" android:layout_width="fill_parent" android:layout_height="0dip" android:textSize="20sp" android:textStyle="bold" android:layout_weight="1" android:textColor="@drawable/text_color" android:gravity="center_vertical"/> </LinearLayout> </LinearLayout> Java code: public void onCreate(Bundle b) { super.onCreate(b); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.qianyuinput); LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.listfooter, null); ListView lv=getListView(); lv.addFooterView(v); v.setOnClickListener(new StartNewRecord()); lv.setFocusable(true); lv.setSelection(1); v.setClickable(true); LinearLayout list_panel=(LinearLayout)findViewById(R.id.list_panel); list_panel.setVisibility(LinearLayout.VISIBLE); setListAdapter(new ResultAdapter(this,1,aList)); } private class ResultAdapter extends ArrayAdapter<String> { private ArrayList<String> items; public ResultAdapter(Context context, int textViewResourceId, ArrayList<String> items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.listitem, null); } String o = items.get(position); if (o != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); if (tt != null) { tt.setText(o); } } return v; } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en