2015-12-11 4 views
0

У меня есть ExpandableListView, и у каждого groupView есть EditText. Если я установил edittext android:focusable=true, элемент groupView не может сфокусироваться, а это означает, что группа не может быть расширена. Если я установил ediitext android:focusable=false, тогда edittext не сможет сфокусироваться, а groupView может быть расширен. Я попытался добавить код sheetListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); Но мне кажется бесполезным для меня.Как использовать Edittext в GroupView ExpandableListView, edittext не может сфокусироваться

Вот файл макета GroupView: R.layout.item_receiving_scan_box

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    ... 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="30dp" 
     android:gravity="center_vertical" 
     android:inputType="number" 
     android:ems="7" 
     android:id="@+id/edittext_receiving_scan_box_count_count" 
     android:text="20" 
     android:textSize="12dp" 
     android:focusable="false" 
     android:clickable="true" 
     android:layout_alignTop="@+id/text_receiving_scan_box_scan_count" 
     android:layout_toRightOf="@+id/text_receiving_scan_box_scan_count" 
     android:layout_toEndOf="@+id/text_receiving_scan_box_scan_count" /> 
</RelativeLayout> 

Вот мой ExpandableListViewAdapter getGroupView код

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    RelativeLayout layout= (RelativeLayout) mLayoutInflater.inflate(R.layout.item_receiving_scan_box, null); 
    TextView matCode = (TextView) layout.findViewById(R.id.text_receiving_scan_box_mat_code); 
    TextView boxCount = (TextView) layout.findViewById(R.id.text_receiving_scan_box_count); 
    matCode.setText(matCode.getText()+mReceivingBoxes.get(groupPosition).get("matCode")); 
    boxCount.setText(boxCount.getText()+mReceivingBoxes.get(groupPosition).get("boxCount")); 
    return layout; 
} 
+0

Вам нужно установить 'setFocusable =" true "', когда расширен ваш групповой профиль. – Piyush

ответ

0

попытка ниже строки в корневом макете: -

before_descendent 

в вашем xml

+0

Корневой макет, вы имеете в виду макет группового просмотра или макет актуарности? – Adam

Смежные вопросы