我想让listview无法选择且无法点击.我在谈论点击列表项时发生的颜色变化.代码如下.我是
android的新手,所以请善待.
来自:listitem.xml
<?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" android:padding="8px"> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF"/> <TextView android:id="@+id/data" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16px"/> </LinearLayout>
来自:details.java
TestActionAdapter() { super(TestDetails.this,R.layout.action_list_item,actions); } @Override public View getView(int position,View convertView,ViewGroup parent) { TestAction action = actions.get(position); LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.action_list_item,parent,false); TextView label = (TextView) view.findViewById(R.id.label); label.setText(action.getLabel()); TextView data = (TextView) view.findViewById(R.id.data); data.setText(action.getData()); return view; }
解决方法
看看这里的答案:
@Override public boolean areAllItemsEnabled() { return false; } @Override public boolean isEnabled(int position) { return false; }