androidviewsimplecursoradaptersettextandroid-cursoradapter

How to set view or Activity for dealing with previous listactivity? for example "see full detail page"


This is my ListActivity after clicking on the list it will start a new activity which shows Full detail of each attraction place. I have no idea how to implement Full detail page. Can you guys show me some code of full detail activity which retrieve data from the previous list?

public class AttractionsListActivity extends ListActivity {



    private static MyDB mDbHelper;
    String[] from = new String[] { Constants.TITLE_NAME , Constants.ADDRESS_NAME };
    int[] to = new int[] {R.id.place_title, R.id.place_address};
    private Cursor c;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        mDbHelper = new MyDB(this);
        mDbHelper.open();
        c = mDbHelper.getplaces();
setListAdapter(new SimpleCursorAdapter(this, 
                  R.layout.list_place, c, 
                  from, to));

        final ListView lv = getListView();

lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View view,int position, long id) {

                Intent newActivity = new Intent(view.getContext(), Place.class);     
                startActivity(newActivity);

            }
          });
    }

}

I have no idea how to implement this activity to deal with the action from AttractionslistActivity.Class


public class Place extends Activity {
    private static final String CLASSTAG = Place.class.getSimpleName();

    private TextView title;
    private TextView detail;
    private TextView location;
    private TextView phone;
    private ImageView placeImage;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v(Constants.TAG, " " + Place.CLASSTAG + " onCreate");

        this.setContentView(R.layout.detail_place);


        this.title = (TextView) findViewById(R.id.name_detail);
        //title.setText(cursor.getString(Constants.TITLE_NAME));
        this.detail = (TextView) findViewById(R.id.place_detail);
        this.location = (TextView) findViewById(R.id.location_detail);
        this.phone = (TextView) findViewById(R.id.phone_detail);
        this.placeImage = (ImageView) findViewById(R.id.place_image);
    }
}

Solution

    1. Override onListItemClick(...) in your List Activity, using the Cursor get the id of the selected item
    2. Start your Detail Activity passing the id through the intent extras
    3. In your Detail Activity, recover the id and open a cursor to get your data back from the DB.
    4. Fill your view with the data