I have created two simple list views. In the first list view I have put category as the item name. And it is the only item which i have included in list one. In the list view I jave put lot of items , say for example orange, Apple, Mango , Banana etc.what i want to know is that if the user selects one particular item in the second list view , I want the selected item to be shown in the first list view.So that it is easy to identify the item which was earlier selected by the user. please help me....
This is my 1st list view code:
public class bview extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, cat));
getListView().setTextFilterEnabled(true);
}
static final String[] cat = new String[] {
"Category", };
protected void onListItemClick(ListView parent, View v, int position,
long id) {
Intent intent= new Intent(bview.this,listview.class);
startActivity(intent);
//intent.putExtra("value", value);
}}
2nd listview code:
public class listview extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.submain);
ListView mlistView = (ListView) findViewById(R.id.listview);
mlistView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
new String[] {"orange", "apple","mango","banana","grapes"}));
mlistView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,long arg3){
Intent in2 =new Intent(listview.this, bview.class);
startActivity(in2);
}
public void onNothingSelected(AdapterView<?>arg0){
}});
}}
I used onitemselected but if click orange nothing will be happend. where i should go to wrong in my code....