Try this code out:
Sending Activity
public void registerCallClickBack() {
ListView list = (ListView) findViewById(R.id.listView1);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked,
int position, long id) {
TextView tv1 =(TextView)viewClicked.findViewById(R.id.stock_name);
TextView tv2 =(TextView)viewClicked.findViewById(R.id.stock_price);
Intent intent = new Intent(MainActivity.this, StockItem.class);
intent.putExtra("name", tv1.getText().toString());
intent.putExtra("price",tv2.getText().toString());
//passes all you stock info (note you do not need the above 2 lines)
intent.putExtra("stockInfo", stocksList.get(position));
startActivity(intent);
}
});
}
Receiving activity
HashMap<String, String> hashMap = (HashMap<String, String>) getActivity().getIntent().getSerializableExtra("stockInfo");