0
我正在Eclipse中为Android开发一个应用程序。目前我的目标是API级别3,但我错误地在Android 1.6模拟器(API级别4)上进行了测试。在1.6上它工作正常,但在1.5我的ListView与CHOICE_MODE_SINGLE不会选择项目,当他们被点击。ListView不检查Android上的项目1.5
这里是我的ListView XML:
<ListView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:id="@+id/ListDomains"
android:layout_margin="5px"
android:choiceMode="singleChoice"
android:clickable="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
>
</ListView>
下面是在ListView的项目的XML:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:id="@+id/domain_list_value"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
>
</CheckedTextView>
我创建一个自定义的ArrayList适配器,让我定制getView。下面是DomainArrayAdapter代码:
public class DomainArrayAdapter extends ArrayAdapter<char[]> {
private LayoutInflater mInflater;
public DomainArrayAdapter(Context context, int textViewResourceId,
List<char[]> objects) {
super(context, textViewResourceId, objects);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = mInflater.inflate(R.layout.domain_list, null);
}
char[] text = super.getItem(position);
((CheckedTextView)convertView).setText(text, 0, text.length);
return convertView;
}
}
的所有这些代码工作正常编译对API级别3和在Android 1.6模拟器中运行。但是,针对1.5模拟器运行时,ListView中的项不会在点击时进行检查。
任何想法?