English 中文(简体)
EditText 重点不一
原标题:EditText focus inconsistent across layouts

我有两种不同的主轴文档,一种是孔隙,一种是布局。 每个人都在一份情况表内有这一守则。

<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>

......

奇怪的是:就我所知,你不应能够提及在Xml发生的 t事件,因此,由于电话的传说,甲状腺素:nextFocusDown=“@id/phone”应当失败;这正是我的地貌Xml发生的事情,而不是在孔隙发生的事情。 在孔隙中,它完美地运作,并通过所有四个无照的EditText。 如果我把下一个焦点放在地貌上,那么它就将无法汇编成册,称“没有发现与特定名称相匹配的资源(在下一个顶点,其价值为@id/phone )。

A solution or explanation would be great. The idea is that I have four text boxes in two different LinearLayouts and whichever one has focus first will pass it to the EditText beneath it, skipping the others. I want it to work as I have it in portrait layout, when the user hits next on the name, focus moves to phone, when they hit next on that it moves to email, etc. I m also curious as to why it is letting this work in portrait but not landscape.

问题回答

This is a really old post but I m answering it as best I can. From what I know you put the + sign the first time you are referencing the id, so on your: android:nextFocusDown="@id/phone" should actually be android:nextFocusDown="@+id/phone because it is the first time you are referencing that object. Then take out the + sign where you have android:id="@+id/phone"

Hope this helps anyone who comes across this.

You are using "@id/phone" try using "@+id/phone" the + is necessary to reference the id of the object





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签