Android ExpandableListView组中的微调器
在我的项目中,我在可展开的listview的每个组中实现了一个微调器,并且组项仍然是可展开的 当我使用光标适配器填充微调器时,问题就开始了。组项目及其指示器变得不可读取,因此它们不会打开 该组有一个自定义布局,其中包含一个复选框,这两个视图都已设置为focasable=falseAndroid ExpandableListView组中的微调器,android,android-layout,expandablelistview,android-spinner,Android,Android Layout,Expandablelistview,Android Spinner,在我的项目中,我在可展开的listview的每个组中实现了一个微调器,并且组项仍然是可展开的 当我使用光标适配器填充微调器时,问题就开始了。组项目及其指示器变得不可读取,因此它们不会打开 该组有一个自定义布局,其中包含一个复选框,这两个视图都已设置为focasable=false @Override public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) { Call call = (Call)
@Override
public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
Call call = (Call) getGroup(i);
if (view == null) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.simple_expandable_list_item_call,null);
}
TextView textViewCallProductName = (TextView) view.findViewById(R.id.text1);
Spinner spinnerCallPurpose = (Spinner) view.findViewById(R.id.spinnerCallReason);
dbHelper mDb = new dbHelper (context);
mDb.open();
Cursor c = mDb.getPurposes();
SimpleCursorAdapter adapter = new SimpleCursorAdapter(context,android.R.layout.simple_spinner_item,c,new String[]{"purpose_name"},new int[]{android.R.id.text1} );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCallPurpose.setAdapter(adapter);
if ( call.product == null ){
textViewCallProductName.setText("Null");
}
else{
textViewCallProductName.setText(call.product.name);}
return view;
}
下面是组布局simple\u expandable\u list\u item\u call.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="50dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:textAlignment="viewStart"
android:text="gfg"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Samples"
android:id="@+id/textView26"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Reason"
android:id="@+id/textView19"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinnerCallReason"
android:prompt="@string/select_purpose"
android:focusable="false"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Giveaway"
android:id="@+id/checkBox2"
android:focusable="false"
android:checked="false"/>
选项包括:
1) 子类化微调器并覆盖驱动弹出对话框的任何内容2) 将微调器复制到项目中,并替换弹出对话框的驱动因素(如果由于方法可见性等原因,重写将不起作用)
3) 不要使用微调器,而是使用按钮加上包含ExpandableListView的AlertDialog,或者类似的东西。您可以通过在组项目xml的父布局中设置以下属性来实现这一点: android:genderantfocusability=“blocksDescendants”
这些都是替代方案,而不是问题的解决方案。有些已经实现了,但这是一个UI问题