首页 > 移动平台 > 详细

Android软键盘问题

时间:2014-10-07 21:09:34      阅读:336      评论:0      收藏:0      [点我收藏+]

一:有EditTexit时自动获取焦点
      1、获得焦点不弹出输入框, 隐藏软键盘;     

     2、不让文本框获得焦点;

     方法一:

        在<activity>标签中加入: android:windowSoftInputMode = "stateHidden"

     方法二:

       在OnCreate()中

getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)

    方法三:

   我们可以抢占文本框的焦点,如在其父窗体中加入:
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:context=".MainActivity" >
      <EditText
         android:id="@+id/etMsg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
     </LinearLayout> 

二:默认弹出的键盘模式就是数字键盘。

EditText et = (EditText) findViewById(R.id.editNum);
         et.setInputType(InputType.TYPE_CLASS_NUMBER);
给你的EditText设置输入类型 TYPE_CLASS_NUMBER,这样你在点击EditText的时候,默认弹出的键盘模式就是数字键盘。

Android软键盘问题

原文:http://my.oschina.net/u/1389206/blog/324722

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!