如何停止软键盘自动显示合焦时改变(的OnStart事件) [英] How to stop Soft keyboard showing automatically when focus is changed (OnStart event)

查看:178
本文介绍了如何停止软键盘自动显示合焦时改变(的OnStart事件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发采用Android 2.2平板电脑。

我有我使用新的和可编辑的实例的形式。当编辑,我想停止从编辑某些领域的用户。我管理这个在我的 ONSTART -event,设置 txt.setFocusableInTouchMode(假)。 这迫使焦点转移到下一个可成为焦点的EditText 在我的形式(这是伟大的),但在运行时,软键盘将自动显示为的EditText 的焦点。 任何人都知道如何停止?

这里的code(称为在 ONSTART 事件):

 私人无效PopulateFields(){
    TextView的txtTitle =(TextView中)this.findViewById(R.id.txtEquipmentEditTitle);
    AutoCompleteTextView txtMake =(AutoCompleteTextView)this.findViewById(R.id.autEquipmentEditMake);
    AutoCompleteTextView txtModel =(AutoCompleteTextView)this.findViewById(R.id.autEquipmentEditModel);
    EditText上txtDesc =(EditText上)this.findViewById(R.id.txtEquipmentEditDesc);
    TextView的txtDeptKey =(TextView中)this.findViewById(R.id.txtEquipmentEditDeptKey);
    EditText上txtSerial =(EditText上)this.findViewById(R.id.txtEquipmentEditSerialNo);
    EditText上txtBar code =(EditText上)this.findViewById(R.id.txtEquipmentEditBar code);

    txtTitle.setText(编辑设备);
    txtMake.setText(使);
    txtModel.setText(模型);
    txtDesc.setText(DESC);
    txtDeptKey.setText(Integer.toString(deptKey));
    txtSerial.setText(串行);
    txtBar code.setText(酒吧code);
    txtMake.setEnabled(假);
    txtModel.setEnabled(假);
    txtDesc.setEnabled(假);
    txtMake.setClickable(假);
    txtMake.setFocusableInTouchMode(假);
    txtModel.setFocusableInTouchMode(假);
    txtDesc.setFocusableInTouchMode(假);
    txtMake.setFocusable(假);
    txtModel.setFocusable(假);
    txtDesc.setFocusable(假);
}
 

解决方案

也许这将帮助你:

  getWindow()setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)。
 

I am developing for a tablet using Android 2.2.

I have a form which I am using for new and editable instances. When editable, I want to stop the user from editing certain fields. I manage this in my onStart-event, setting the txt.setFocusableInTouchMode(false). This forces the focus to the next focusable EditText in my form (which is great), but when running, the soft keyboard automatically appears for the EditText with the focus. Anybody know how to stop this?

Here's the code (called in the onStart event):

private void PopulateFields(){
    TextView txtTitle = (TextView) this.findViewById(R.id.txtEquipmentEditTitle);
    AutoCompleteTextView txtMake = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditMake);
    AutoCompleteTextView txtModel = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditModel);
    EditText txtDesc = (EditText) this.findViewById(R.id.txtEquipmentEditDesc);
    TextView txtDeptKey = (TextView) this.findViewById(R.id.txtEquipmentEditDeptKey);
    EditText txtSerial = (EditText) this.findViewById(R.id.txtEquipmentEditSerialNo);
    EditText txtBarCode = (EditText) this.findViewById(R.id.txtEquipmentEditBarCode);

    txtTitle.setText("Edit Equipment");
    txtMake.setText(make);
    txtModel.setText(model);
    txtDesc.setText(desc);
    txtDeptKey.setText(Integer.toString(deptKey));
    txtSerial.setText(serial);
    txtBarCode.setText(barCode);
    txtMake.setEnabled(false);
    txtModel.setEnabled(false);
    txtDesc.setEnabled(false);
    txtMake.setClickable(false);
    txtMake.setFocusableInTouchMode(false);
    txtModel.setFocusableInTouchMode(false);
    txtDesc.setFocusableInTouchMode(false);
    txtMake.setFocusable(false);
    txtModel.setFocusable(false);
    txtDesc.setFocusable(false);
}

解决方案

Maybe this will help you:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

这篇关于如何停止软键盘自动显示合焦时改变(的OnStart事件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆