I\'m a new programmer and new in Android. I\'m using this example http://www.androidhive.info/2012/09/android-adding-search-functionality-to-listview/ and it works great.
well in your onitemClick
you will send the selected value like deal
, and send it in your intent when opening new activity and in your new activity get the sent data and related to selected item will display your data
to get the name from the list
String item = yourData.get(position).getName();
to set data in intent
intent.putExtra("Key", item);
to get the data in second activity
getIntent().getExtras().getString("Key")
listview.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?>adapter,View v, int position){
Intent intent;
switch(position){
case 0:
intent = new Intent(Activity.this,firstActivity.class);
break;
case 1:
intent = new Intent(Activity.this,secondActivity.class);
break;
case 2:
intent = new Intent(Activity.this,thirdActivity.class);
break;
//add more if you have more items in listview
//0 is the first item 1 second and so on...
}
startActivity(intent);
}
});
In your activity, where you defined your listview
you write
listview.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?>adapter,View v, int position){
ItemClicked item = adapter.getItemAtPosition(position);
Intent intent = new Intent(Activity.this,destinationActivity.class);
//based on item add info to intent
startActivity(intent);
}
});
in your adapter's getItem you write
public ItemClicked getItem(int position){
return items.get(position);
}