建议需要用右键菜单需要用、右键菜单、建议

2023-09-04 05:17:43 作者:大概是你喜欢花朵我姓曹

我有一个XML布局里面有两个编辑文本字段,一个是冠军和其他的故事。当用户输入这些文本框和$ P $他的数据psses后退按钮进入被保存在一个列表视图作为标题集。列表视图是present在活动中说,A1。现在A1扩展了活动。

I have a XML layout which has two edit text fields, one for "title" and the the other for "story". When the user enters his data in these text fields and presses the back button the entry gets saved in a list view as the title set. The list view is present in an activity say A1. Now A1 extends Activity.

只要在列表中的项目是长点击上下文菜单显示与编辑,删除和读取按钮。如果编辑按钮是pressed我需要打开,可以编辑对应的项目点击的文本字段中输入的数据的另一个活动。另外我会需要的ID,并点击列表中的项目的位置。

Whenever an item in the list is "long clicked" a context menu appears with edit, delete and read buttons. If the edit button is pressed I need to open another activity which can edit the data entered in the text fields corresponding to the item clicked. Also I'd be needing the id and the position of the item clicked in the list.

我使用的类型的ListView列表变量添加我的适配器。另外我检查了编辑,删除和读取上下文菜单中的选项在`公布尔onContextItemSelected(菜单项项目)的方法。

I am using list variable of type ListView to add my adapter. Also I am checking the edit, delete and read options of the context menu in the `public boolean onContextItemSelected(MenuItem item)' method.

我怎样才能获得ID,而该项目的位置,从这里点击?

How can I get the id and the position of the item clicked from here?

推荐答案

在适配器,你让你的项目的getter和setter。当长按监听器,把二传手在那里,你的项目。

in adapter you make a getter and setter of your item. When long click listener, put setter your item in there.

您储存您的标题和故事,在数据库中,你可以得到它形成数据库中的一个新的活动

You should store your "title" and "story" in database and you can get it form database in a new activity

 
精彩推荐
图片推荐