@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myDbHelper = new RestaurantApp2_DBAdapter(this); myDbHelper.open(); setContentView(R.layout.record_detail); setTitle(R.string.detail_record); nameText = (TextView) findViewById(R.id.name); addressText = (TextView) findViewById(R.id.address); phoneText = (TextView) findViewById(R.id.phone); // noteText = (TextView) findViewById(R.id.note); ratingbarValue = (RatingBar) findViewById(R.id.ratingbar); // latitudeText = (TextView) findViewById(R.id.latitude); // longitudeText = (TextView) findViewById(R.id.longitude); mRowId = (savedInstanceState == null) ? null : (Long) savedInstanceState.getSerializable(RestaurantApp2_DBAdapter.KEY_ROWID); if (mRowId == null) { Bundle extras = getIntent().getExtras(); mRowId = extras != null ? extras.getLong(RestaurantApp2_DBAdapter.KEY_ROWID) : null; } populateFields(); }
private void populateFields() { if (mRowId != null) { Cursor record = myDbHelper.fetchRecord(mRowId); startManagingCursor(record); nameText.setText( record.getString(record.getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_NAME))); addressText.setText( record.getString(record.getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_ADDRESS))); phoneText.setText( record.getString(record.getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_PHONE))); // noteText.setText(record.getString(record // .getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_NOTE))); ratingbarValue.setRating( record.getFloat(record.getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_RATING))); // --------------------------------------------------------------------------------- // latitudeText.setText(record.getString(record // .getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_LATITUDE))); // longitudeText.setText(record.getString(record // .getColumnIndexOrThrow(RestaurantApp2_DBAdapter.KEY_LONGITUDE))); } }