我将一些项目显示为列表,我想知道是否有一种方法可以在屏幕右侧为列表中的每个项目添加一个小下拉列表,提供删除/编辑选项。
这可能吗? Rigth现在我列出这样的事情:
<?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>
谢谢!
答案 0 :(得分:2)
如果您想要看起来不错,请使用quickaction-dialog
选项菜单。
这里是整个例子quickaction-dialog
答案 1 :(得分:1)
只需在ur list item layout中添加微调器,然后在getView()方法中将adapter设置为tat spinner。
代表。 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>
然后UR getView()
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
final ViewHolder viewHolder;
if (view == null) {
viewHolder = new ViewHolder();
view = mInflater.inflate(R.layout.list_item,
null);
viewHolder.nameTV = (TextView) view
.findViewById(R.id.nameTV);
viewHolder.actionSP = (Spinner) view
.findViewById(R.id.actionSP);
ArrayAdapter<String> reasonAdapter = new ArrayAdapter<String>(
mApplication, android.R.layout.simple_spinner_item,
mYourActionsArray);
reasonAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
viewHolder.actionSP.setAdapter(reasonAdapter);
viewHolder.actionSP
.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0,
View arg1, int position, long arg3) {
}
});
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
viewHolder.nameTV.setText("Some Value");
返回视图; }
ViewHolder类
class ViewHolder {
TextView nameTV;
Spinner actionSP;
}