Deepak Rai

Deepak Rai

  • NA
  • 45
  • 8.7k

Pass the data of ListView from one activity to other.

Oct 21 2018 1:39 AM
I added two Activities 1. Tab1 and 2. TrendSingle
 
I want to pass the data of selected ListView from One Activity(Tab1) to other Activity(TrendSingle).
 
I am using Intent it passes the values from one Activity to Other but in the form of
selectedIndex I want to pass the content of selected ListView.
 
Here is my code:
 
Tab1
 
Intent intent = new Intent(getActivity(),TrendSingle.class);
intent.putExtra("NewsTit",listView.getItemAtPosition(position).toString());
startActivity(intent);
 
TrendSingle
 
Bundle bundle = getIntent().getExtras();
if(bundle != null)
{
String s = bundle.getString("NewsTit");
TextView textView = (TextView) findViewById(R.id.textTit);
textView.setText(s);
}
 
please help me

Answers (2)