`
wang_peng1
  • 浏览: 3904980 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

阻止EditText 开始就获得焦点

阅读更多

在listView中或其他格式中存在editView,尤其是listView和editView并存的时候 程序运行veditvview 就获得焦点,如何让他不获得焦点呢

EditText.setSelected(false);

上述命令是不行的。

clearFocus() 才是可以的。

 

如果你是用AutoCompleteTextView

<!-- 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/text"
       
android:layout_width="fill_parent" android:layout_height="wrap_content"
       
android:nextFocusUp="@+id/text" android:nextFocusLeft="@+id/text"/>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics