lundi 18 mai 2015

won't show me the data that i pass to another activity

here is my code for first activity:

public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(Categories.this, Books.class);
final String selectedCategory = (String) parent.getSelectedItem();
i.putExtra("category", selectedCategory);
startActivity(i);
}

and here is for my second activity:

Intent passedCategory =getIntent();
String vCategory = passedCategory.getStringExtra("category");
TextView v = (TextView)findViewById(R.id.CategoryPass);
v.setText(vCategory);

CategoryPass -- id of TextView in XML file

and when i run this it wont show me anything in the TextView, am i doing something wrong ?

Aucun commentaire:

Enregistrer un commentaire