dyl*_*phy 11 xml android orientation
我有两个不同的main.xml文件,一个用于纵向,一个用于布局.每个人都在Scrollview内部的RelativeLayout中包含此代码.
<LinearLayout
android:id="@+id/name_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/acquire"
>
<EditText
android:id="@+id/name"
android:inputType="textPersonName"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="observer name"
android:nextFocusDown="@id/phone"
android:background="@android:drawable/editbox_background"
/>
<EditText
android:id="@+id/phone"
android:inputType="phone"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="phone number"
android:nextFocusDown="@id/phone"
android:background="@android:drawable/editbox_background"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
等......
怪异的是:据我所知,你是不是应该能够指还没有在XML中没有发生过的事情,因此Android:nextFocusDown ="@ ID /手机",因为手机处理不当被宣布失效; 这就是我的风景xml中发生的事情,但不是肖像.在肖像中它完美地工作,并通过所有四个EditTexts传递焦点,没有任何障碍.如果我将NextFocusDown放入格局中,它将无法编译,声明"找不到与给定名称匹配的资源(在'nextFocusDown'处,值为'@id/phone')."
解决方案或解释会很棒.我的想法是,我在两个不同的LinearLayouts中有四个文本框,无论哪个有焦点,首先会将它传递给它下面的EditText,跳过其他的.我希望它能够像我在纵向布局中那样工作,当用户点击名称的下一个,焦点移动到手机,当他们点击它接下来它移动到电子邮件等时.我也很好奇为什么它是让这个工作在纵向而不是景观.
小智 22
这是一个非常古老的帖子,但我尽我所能回答它.据我所知,你在第一次引用id时放了+号,所以在你的:
android:nextFocusDown="@id/phone"应该是android:nextFocusDown="@+id/phone因为它是你第一次引用那个对象.然后取出你所拥有的+号
android:id="@+id/phone"
希望这有助于任何遇到此问题的人.