on the caller activity I have:
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent myIntent = new Intent(MainActivity.this, sondaggioActivity.class);
myIntent.putExtra("categoriaId", String.valueOf(id));
MainActivity.this.startActivity(myIntent);
// Toast.makeText(this, String.valueOf(id), Toast.LENGTH_LONG).show();
}
the toast return the right value of the id of the item clicked on the list. on the reciver activity i have:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maindomanda);
int category = getIntent().getExtras().getInt("categoriaId");
TextView text = (TextView) findViewById(R.id.domanda);
text.setText(String.valueOf(category));
}
a very straight forward... the text field returns always 0... what i'm doing wrong? is the String.ValueOf() somehow deprecated? or is better to use something else...
and another side question... i pass the long id
like i know what i'm doing, it's quite false... is it the so called "_ID
" field? i get those values from a dbtable, is that that table ID?