Android界面加载完成后自动弹出软键盘的解决方案

news/2024/7/4 9:41:17

       在android中有多个可供输入的控件时候,加载之后,第一个可输入控件获取焦点。因此加载完毕输入软键盘弹出,采用获取焦点触摸模式可以解决问题,特此机制。

只需要在最外层的容器中添加以后语句即可。

    android:focusable="true"

    android:focusableInTouchMode="true"
例如:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="
http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:gravity="fill"
 >
 <include android:layout_width="fill_parent"
    android:layout_height="40dp"
     layout="@layout/query_ems_header"/>
 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  
android:focusable="true"
  android:focusableInTouchMode="true"
  >
  <EditText
   android:id="@+id/tv_ems_code"
   android:layout_width="0dip"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   >
  </EditText>
  <Button
      android:id="@+id/btn_scanner_coder"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginLeft="@dimen/common_view_margin"
      android:background="@drawable/scanner"
      />
 </LinearLayout>
    <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">

  <Spinner
      android:id="@+id/spinner_common_companys"
      android:layout_width="0dip"
      android:layout_weight="1"
      android:layout_height="wrap_content"
      >
  </Spinner>
  <EditText
   android:id="@+id/tv_ems_company_name"
   android:layout_width="0dip"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:hint="快递公司-拼音"
    />
 </LinearLayout>
 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <Button
   android:id="@+id/btn_save"
   android:layout_width="0dip"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:text="保存">
  </Button>
  <Button
   android:id="@+id/btn_query"
   android:layout_width="0dip"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:text="查询" />
 </LinearLayout>
 <ListView android:id="@+id/lv_emsDetail"
     android:layout_width="fill_parent"
     android:layout_height="match_parent"
     android:layout_gravity="center_vertical"
     android:choiceMode="singleChoice"
     android:background="@drawable/btn_bg">
    
 </ListView>
</LinearLayout>

详细看上述红色代码,即可。


http://www.niftyadmin.cn/n/4565892.html

相关文章

get方法

接口 - 查询英雄外号 根据英雄名返回英雄外号 接口地址 - /getNickName 请求方式 - get 请求参数 - heroName 返回值 - 英雄外号 //导包 const express require(express) //创建服务器 const app express()//写接口 app.get(/getNickName,(req,res)>{//要接收前端传递过来…

android程序开源源码贡献

Android PDF 阅读器 http://sourceforge.net/projects/andpdf/files/ 个人记账工具 OnMyMeans http://sourceforge.net/projects/onmymeans/develop Android电池监控 Android Battery Dog http://sourceforge.net/projects/andbatdog/ RSS阅读软件 Android RSS http://code.goo…

Android中父子窗体调用类似模式窗体应用

在我们学习其他语言&#xff08;javascript&#xff0c;C#,J2SE AWT&#xff09;的时候可能会遇到模式窗体的概念&#xff0c; 就是一个父窗体&#xff0c;打开一个子窗体&#xff0c;关闭子窗体时候&#xff0c;获取父窗体界面的数值。 大致步骤&#xff1a; 1.一个Activity…

简易的app

//导包 const express require(express) const bodyParser require(body-parser) const path require(path) var multer require(multer) const { cpuUsage } require(process) const { fstat } require(fs)//用包创建一个文件夹 var upload multer({data:uploads/})//导…

Android文件图片上传的详细讲解(一)HTTP multipart/form-data 上传报文格式实现手机端上传...

做一个文件上传到服务器端可能需要以下几点知识&#xff0c;如下&#xff1a; 1.HTTP multipart/form-data 上传报文格式实现手机端上传&#xff1a; 2.选择图片&#xff0c;采用android中父子窗体回调的模式窗体。 3.android 中AsyncTask的使用 4.服务端fileupload文件读写 效…

同源与不同源

同源 - 协议和地址和端口都一样 不同源 - 协议和地址和端口&#xff0c;只要有一个不同就不同源 解决跨域问题 //设置响应头&#xff0c;允许资源被访问/共享 res.setHeader(‘Access-Control-Allow-Origin’,’*’)//表示所有的请求路径都可以请求这个接口 //中间件 //使用…

Android文件图片上传的详细讲解(二)--AsyncTask的用法

AsyncTask的用法 AsyncTask的用法 在开发Android应用时必须遵守单线程模型的原则&#xff1a; Android UI操作并不是线程安全的并且这些操作必须在UI线程中执行。在单线程模型中始终要记住两条法则&#xff1a; 1. 不要阻塞UI线程 2. 确保只在UI线程中访问Android UI…

cookie工作流程

类比于后台服务器的使用 //登录接口 app.get(/login,(req,res)>{//假如现在这里已经验证了账号和密码&#xff0c;是正确的&#xff0c;是可以登录的//服务器就会吧cookie响应回去res.writeHead(200,{Content-Type:text/plain; charsetutf-8,"Set-Cookie":userid…