zoukankan      html  css  js  c++  java
  • 【Android笔记】EditText文本框不获取焦点

    在开发中,常常会碰到这种情况,打开一个activity后,

    第一个文本框自动获得焦点,同时会弹出软键盘输入框,这样很影响用户体验。

    解决方法:

     1、不让文本框获得焦点,抢占文本框的焦点,如在其父窗体中加入:

     1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     xmlns:tools="http://schemas.android.com/tools"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:orientation="vertical"
     6     android:focusable="true"
     7     android:focusableInTouchMode="true"
     8     tools:context=".MainActivity" >
     9      
    10      <EditText
    11         android:id="@+id/etMsg"
    12         android:layout_width="wrap_content"
    13         android:layout_height="wrap_content"
    14         />
    15 </LinearLayout>

     2、获得焦点不弹出输入框,在activity中加入:

    1 android:windowSoftInputMode = "stateHidden"

    参考原文:http://my.oschina.net/helu/blog/142020

  • 相关阅读:
    CSPS模拟 65
    CSPS模拟 64
    $color$有色图
    CSPS模拟 63
    CSPS模拟 62
    CSPS模拟 61
    CSPS模拟 60
    CSPS模拟 59
    go中单链表
    MYSQL-联合索引
  • 原文地址:https://www.cnblogs.com/tanghuian/p/4602261.html
Copyright © 2011-2022 走看看