Reputation: 7014
My requirement is highlight first row form list when the activity load(initial listview should be highlighted.).
I have done like this
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sales_routes);
ArrayList<Object> routeList = getWmRoute();
ArrayList<String> routhPath = new ArrayList<String>();
for(int i = 0; i<routeList.size();i++){
routhPath.add(((WMRoute) routeList.get(i)).getDescription());
}
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_two_column, R.id.FROM_CELL, routhPath));
ListView list = getListView();
list.setSelected(true);
list.setSelection(0);
list.getItemAtPosition(0);
System.out.println(" ========= " + list.getItemAtPosition(0));
list.setFocusable(true);
list.requestFocus();
This is not selected that particular row.
I have to select first row as well as select the radio button also.
Please help me.
please help me this.
Thanks in advance.
Upvotes: 1
Views: 767
Reputation: 15477
You can try
requestFocus() method;
list.getChildAt(0).setSelection(true);
method may be getChildAtPosition(0)
.See what is available.I am confused
Upvotes: 1