java可扩展列表视图编辑文本焦点捕捉到xml中列出的第一个焦点

4zcjmb1e  于 2021-07-04  发布在  Java
关注(0)|答案(0)|浏览(212)

在我的可扩展列表视图中有两个编辑文本。我不能让两者都有集中注意力的能力。每当我单击非工作视图时,焦点将设置一秒钟,然后快速回到另一个。保持焦点的似乎是xml中最先列出的那个(我使用相对布局来定位,所以xml中的顺序在其他方面并不重要)。我试着添加

android:focusableInTouchMode="true"
android:focusable="true"

到相对布局,然后更改它,以便列出的第二个edittext可以保留焦点,但列出的第一个不能(它可能会捕捉到相对布局)。我也尝试过添加 android:windowSoftInputMode="adjustPan" 但这对功能没有明显的影响。
以下是EditText的xml:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="120dp"
    android:layout_width="match_parent"
    android:id="@+id/VAR_EXPENSES_GROUP">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toStartOf="@id/VAR_EXPENSES_GROUP_BUTTON"
        android:layout_alignTop="@id/payment_sign"
        android:paddingTop="20dp"
        android:inputType="numberDecimal"
        android:textSize="24sp"
        android:text="0.00"
        android:id="@+id/VAR_EXPENSES_GROUP_PAYMENT"/>

    <EditText
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:text="Payment Description"
        android:id="@+id/VAR_EXPENSES_GROUP_DESCRIPTION"
        android:layout_below="@id/h_divider"
        android:layout_above="@id/b_divider"
        android:layout_toEndOf="@id/v_divider"
        android:gravity="center"/>

</Relative Layout>

我在expandablelistadapter getgroupview中没有触及焦点,当使用调试器运行它时,焦点似乎转移到该函数之外。谢谢您!
--编辑--
原来我把 android:windowSoftInputMode="adjustPan" 在我舱单上的错误位置。加上`android:descendantfocusability=可扩展列表视图xml的“后继子代”似乎已经解决了这个问题。如果有人能解释为什么这些是必要的,那将是伟大的/任何替代品!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题