I want to make a ListItem
selected as app starts and get the text/value of selected item,but I'm unable to do.
Code
public class MenuList extends ListActivity {
String[] classNames = {"MainActivity", "example"};
//private View currentSelectedView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(MenuList.this, android.R.layout.simple_list_item_1, classNames));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String itemText= classNames[position];
Toast.makeText(MenuList.this, itemText, Toast.LENGTH_LONG).show();
}
}
through this I get the text/value of listItem but Im unable to make a listItem pre-selected. can any-one tell me how to do so..?