小编Run*_*gen的帖子

如何停止更改焦点时自动显示软键盘(OnStart事件)

我正在开发使用Android 2.2的平板电脑.

我有一个表单,我用于新的和可编辑的实例.可编辑时,我想阻止用户编辑某些字段.我在我的onStart-event中设置了这个,设置了txt.setFocusableInTouchMode(false).这会强制焦点转到下一个可聚焦EditText的形式(这很棒),但在运行时,软键盘会自动显示EditText焦点.谁知道如何制止这个?

这是代码(在onStart事件中调用):

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);
}
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard android-edittext

27
推荐指数
3
解决办法
3万
查看次数