简体   繁体   English

如何使用Edittext在ExpandableListView的GroupView中,edittext无法获得焦点

[英]How to use Edittext In GroupView of ExpandableListView, edittext cannot get focused

I have a ExpandableListView and each groupView has a EditText . 我有一个ExpandableListView ,每个groupView都有一个EditText If I set the edittext android:focusable=true then the groupView item cannot get focused, which means the group can't be expanded. 如果我将edittext设置为android:focusable=true focusable android:focusable=true则groupView项无法聚焦,这意味着该组无法展开。 If I set the ediitext android:focusable=false , then the edittext cannot get focused while de groupView can be expanded. 如果我将ediitext设置为android:focusable=false focusable android:focusable=false ,则可以扩展degroupView的同时使edittext无法聚焦。 I have tried to add code sheetListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); 我试图添加代码sheetListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); But it seems no use for me. 但这对我来说似乎没有用。

Here is the GroupView layout file: R.layout.item_receiving_scan_box 这是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>

Here is my ExpandableListViewAdapter getGroupView code 这是我的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;
}

try below line in your root layout :- 尝试在您的根目录布局的下面一行:-

before_descendent

in your xml 在你的xml中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM