gpt4 book ai didi

java - Android: "next"单击表单以错误的 View 结束

转载 作者:行者123 更新时间:2023-12-01 05:06:20 25 4
gpt4 key购买 nike

我正在使用以下布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical" >
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:nextFocusRight="@+id/timePicker"
android:nextFocusDown="@+id/timePicker" />
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/datePicker"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:nextFocusLeft="@+id/datePicker"
android:nextFocusUp="@+id/datePicker" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/timePicker"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="0dp"
android:layout_marginTop="2dp"
android:text="@string/button1" />
</RelativeLayout>

我正在尝试使用

进入下一个 View
android:nextFocusRight="@+id/timePicker"
android:nextFocusDown="@+id/timePicker"

但这行不通。当我在 DatePicker 中启动并单击“下一步”时,我得到了错误的 View ,并且具有正常的键盘布局。

有人可以帮忙吗?

最佳答案

我相信您需要做的就是将以下内容添加到您想要聚焦的所有 View 中:

android:focusable="true"
<小时/>

Documentation :

Focus Handling

The framework will handle routine focus movement in response to user input. This includes changing the focus as views are removed or hidden, or as new views become available. Views indicate their willingness to take focus through the isFocusable() method.

<小时/>

isFocusable()

Returns whether this View is able to take focus.

Related XML Attributes
android:focusable

Returns
True if this view can take focus, or false otherwise.

关于java - Android: "next"单击表单以错误的 View 结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12610833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com