如何设置视图或活动来处理先前的列表活动?例如“查看完整的详细信息页面”

Apr*_*ith 6 android view settext simplecursoradapter android-cursoradapter

这是我的ListActivity ,单击列表后,它将启动一个新列表activity,其中显示每个景点的完整详细信息。我不知道如何实现完整的详细信息页面。你们能给我展示一些从以前的数据中检索数据的完整详细活动的代码吗list

公共类 AttractionsListActivity 扩展 ListActivity {



    私有静态MyDB mDbHelper;
    String[] from = new String[] { Constants.TITLE_NAME , Constants.ADDRESS_NAME };
    int[] to = new int[] {R.id.place_title, R.id.place_address};
    私有游标c;


    @覆盖
    公共无效onCreate(捆绑保存实例状态){
        super.onCreate(savedInstanceState);


        mDbHelper = new MyDB(this);
        mDbHelper.open();
        c = mDbHelper.getplaces();
setListAdapter(新的SimpleCursorAdapter(这个,
                  R.layout.list_place,c,
                  从到));

        最终ListView lv = getListView();

lv.setOnItemClickListener(new OnItemClickListener() {
            公共无效onItemClick(AdapterView父级,视图视图,int位置,长id){

                Intent newActivity = new Intent(view.getContext(), Place.class);     
                启动活动(新活动);

            }
          });
    }

}

我不知道如何实现此活动来处理 AttractionslistActivity.Class 中的操作

公共类地点扩展活动{
    私有静态最终字符串CLASSTAG = Place.class.getSimpleName();

    私有 TextView 标题;
    私有 TextView 详细信息;
    私有 TextView 位置;
    私人 TextView 电话;
    私有ImageView placeImage;

    公共无效onCreate(捆绑保存实例状态){
        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);
    }
}

aro*_*ero 4

  1. 在列表活动中覆盖onListItemClick(...),使用光标获取所选项目的 id
  2. 启动您的详细活动,通过意图附加传递 id
  3. 在您的详细活动中,恢复 ID 并打开游标以从数据库取回数据。
  4. 用数据填充您的视图