
ensacom
Ambitioniertes Mitglied
Hallo, wie kann ich eine Variable int an eine activity übergeben?
Danke
Danke
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent iFahrzeug_new = new Intent(this, Fahrzeug_New.class);
iFahrzeug_new.putExtra("id", id);
startActivity(iFahrzeug_new);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fahrzeug_new);
Spinner s1 = (Spinner) findViewById(R.id.cb_KfzTreibstoffArt);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.Kraftstoffarten, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
int i = getIntent().getExtras().getInt("id",0);
String a = ""+i;
Toast toast = Toast.makeText(this, a, Toast.LENGTH_SHORT);
toast.show();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final Intent iFahrzeug_new = new Intent(this, Fahrzeug_New.class);
iFahrzeug_new.putExtra("id", id);
startActivity(iFahrzeug_new);
}
Toast toast = Toast.makeText(this, ""+getIntent().getExtras().getLong("id"), Toast.LENGTH_SHORT);
toast.show();