Hi... I have a problem when i'm passing value between activities....i'm using a activity to get information from a database and put into a listview after this I'm using a onListItemClick to call the another activity to show the a details of the item I selected...but when I put the key value of my item Id on Intent method "putExtra" I cant get then into another acitivity... what I'm doing wrong ?! Thanks Igor
here my code: first activity class (Restaurant.java) public class Restaurants extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setContentView(R.layout.restaurants); ListRestaurants(); } catch (Exception e) { // TODO: handle exception Log.e("oncreate resta",e.getMessage()); } } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub //super.onListItemClick(l, v, position, id); String[] FROM = {"_id","res_name", "res_city"}; Intent its = new Intent().setClass(getBaseContext(),RestaurantsDetails.class); DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this); try { dbAdapter.createDataBase(); } catch (IOException e) { // TODO: handle exception Log.e("*** select ",e.getMessage()); } dbAdapter.openDataBase(); Cursor c = dbAdapter.selectRecordsFromDB("restaurants", FROM,null,null,null,null,null); c.moveToPosition(position); its.putExtra("Key",id); startActivity(its); } public void ListRestaurants(){ DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this); String[] FROM = {"_id","res_name", "res_city"}; int[] TO = {R.id._id,R.id.res_name,R.id.res_city}; try { dbAdapter.createDataBase(); } catch (IOException e) { // TODO: handle exception Log.e("*** select ",e.getMessage()); } dbAdapter.openDataBase(); Cursor c = dbAdapter.selectRecordsFromDB("restaurants", FROM,null,null,null,null,null); SimpleCursorAdapter sAdapter = new SimpleCursorAdapter(this,R.layout.restaurant_row,c,FROM,TO); setListAdapter(sAdapter); dbAdapter.close(); } } //Second Activity public class RestaurantsDetails extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setContentView(R.layout.restaurants_details); Bundle extra = getIntent().getExtras(); if (extra != null) { String mRowId = extra.getString("Key"); if (mRowId != null) { TextView txtResId = (TextView)findViewById(R.id.txtResId); txtResId.setText(mRowId); } } } catch (Exception e) { // TODO: handle exception Log.e("oncreate resta",e.getMessage()); } } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en