Android-有没有办法将选项菜单添加到列表项
我将一些项目显示为一个列表,我想知道是否有办法在屏幕右侧为列表中的每个项目添加一个下拉列表,提供删除/编辑选项 可能吗?Rigth现在我列出如下内容:Android-有没有办法将选项菜单添加到列表项,android,android-layout,Android,Android Layout,我将一些项目显示为一个列表,我想知道是否有办法在屏幕右侧为列表中的每个项目添加一个下拉列表,提供删除/编辑选项 可能吗?Rigth现在我列出如下内容: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" androi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="@+id/header"
layout="@layout/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/no_problems"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter the business(es) you want to plan or choose from your existing list."
/>
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px" >
</ListView>
<Button
android:id="@+id/add_problem_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/light_best_blue"
android:text="Plan a New Business"
android:layout_marginTop ="15dp"
/>
</LinearLayout>
在listView中,我有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
谢谢 只需在您的列表项布局中添加微调器,然后使用in getView()方法将适配器设置为tat微调器 对于ex.ur list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/nameTV" android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
<Spinner android:id="@+id/actionSP" android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
只需在您的列表项布局中添加微调器,然后使用in-getView()方法将适配器设置为tat微调器 对于ex.ur list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/nameTV" android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
<Spinner android:id="@+id/actionSP" android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
如果你想看起来不错,那么使用选项菜单的
quickaction对话框
。
这里是整个示例如果你想看起来不错,那么使用
快速动作对话框
作为选项菜单。
这里是整个示例如果您在每个项目中添加上下文菜单不是更好吗?这样,如果用户触摸该项目大约2秒钟,就会弹出一个菜单,您可以在那里添加所有选项。它还将有助于减少混乱。@amanmadaan是的,这可能很好,但许多用户在2秒钟内都不知道触摸菜单:)我认为你应该试试,上下文菜单现在是标准的,所有普通Android用户都知道它们是如何工作的。您可以在帮助文件或弹出窗口中添加有关它们的一些信息。好的,我已经介绍了我的案例:),以防万一你发现它们适合你,请随意看看,如果你在每个项目中添加上下文菜单不是更好吗?这样,如果用户触摸该项目大约2秒钟,就会弹出一个菜单,你可以在那里添加所有选项。它还将有助于减少混乱。@amanmadaan是的,这可能很好,但许多用户在2秒钟内都不知道触摸菜单:)我认为你应该试试,上下文菜单现在是标准的,所有普通Android用户都知道它们是如何工作的。您可以在帮助文件或弹出窗口中添加有关它们的一些信息。好吧,我已经介绍了我的案例:),以防你发现它们适合你,请随意看看我以前从未使用过的纺纱机。它是小型下拉菜单项的另一个名称吗?另外,我不知道如何将下拉菜单项添加到布局xml中listitem的右侧。ya spinner s d在android中的下拉菜单名称,我已经用layoutI更新了我的答案。我以前从未使用过spinner。它是小型下拉菜单项的另一个名称吗?另外,我不知道如何将下拉菜单项添加到布局xml中listitem的右侧。ya spinner s d android中下拉菜单的名称,我已经用LayoutHanks更新了我的答案,我查看了它,但我不知道如何让布局以任何合理的方式呈现它。谢谢,我看了一遍,但我不确定我是否理解如何让布局以任何合理的方式呈现它。
class ViewHolder {
TextView nameTV;
Spinner actionSP;
}