如何设置视图或活动来处理先前的列表活动?例如“查看完整详细信息页面”
这是我的 ListActivity
,单击列表后,它将启动一个新的 activity
,其中显示每个景点的完整详细信息。我不知道如何实现完整的详细信息页面。你们能给我展示一些从之前的列表
中检索数据的完整详细活动的代码吗?
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); } }); } }
我不知道如何实现此活动来处理 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); } }
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); } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
onListItemClick(...)
,使用光标获取所选项目的 idonListItemClick(...)
in your List Activity, using the Cursor get the id of the selected itemAndroid 记事本教程 包含一个具体的示例,如果我理解的话正确提问。
The Android Notepad Tutorial includes an example of exactly this, if I understand the question correctly.