Monday, June 11, 2012

Android:To set an item as selected when the ListView opens

Android:To set an previous selected item as selected when the ListView opens
Problem:
 To set previous selected item as selected when the List View Opens.
Solution:
Make your listview as single choice mode or multible choice mode.
XML Code:
<ListView
              android:id="@+id/_list"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:clickable="true"
              android:choiceMode="singleChoice"
              >
  </ListView>
Activty Code :

listView.setAdapter(new ArrayAdapter<String>(getContext(),android.R.layout.simple_list_item_single_choice, list_array));

jobList.setItemChecked( here your previous position, true);

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...