热门搜索 :
考研考公
您的当前位置:首页正文

启动activity时,让EditText不自动获取焦点

来源:东饰资讯网
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
    android:focusable="true" 
    android:focusableInTouchMode="true"
    android:layout_width="0px" 
    android:layout_height="0px"/>

<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="@+id/autotext"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:nextFocusUp="@id/autotext" 
    android:nextFocusLeft="@id/autotext"/>

Android有自动聚焦行为,它内置于其应用程序结构的核心行为。 如果你告诉它EditText正在释放或失去焦点,它会自动决定焦点在哪里。 如果没有用于焦点转移的新对象,它选择布局中的第一可聚焦元素,即使该元素是刚刚清除其焦点的元素!

Top