Java 忽略Android Nexus的编辑文本设置(2.3.4)
直到Nexus S手机的2.3.4更新之后,我才看到这个问题 我有一个非常简单的应用程序,主要活动在应用程序启动时加载 此主要活动有一个LinearLayout,由一些TextView、EditText、一对微调器和一个按钮组成 我现在对编辑文本的输入有问题。它应该有一个带有电话输入类型的软键盘。相反,它提供了标准的字母数字软键盘,一旦你开始键入输入,它就会将其传递给谷歌搜索应用程序,而根本不填写编辑文本 如果我转到“设置”活动并向后导航,则EditText功能正常 我一辈子都搞不清楚这里到底出了什么问题,我马上就要宣布这是手机2.3.4更新的问题了 活动代码:Java 忽略Android Nexus的编辑文本设置(2.3.4),java,android,nexus-s,Java,Android,Nexus S,直到Nexus S手机的2.3.4更新之后,我才看到这个问题 我有一个非常简单的应用程序,主要活动在应用程序启动时加载 此主要活动有一个LinearLayout,由一些TextView、EditText、一对微调器和一个按钮组成 我现在对编辑文本的输入有问题。它应该有一个带有电话输入类型的软键盘。相反,它提供了标准的字母数字软键盘,一旦你开始键入输入,它就会将其传递给谷歌搜索应用程序,而根本不填写编辑文本 如果我转到“设置”活动并向后导航,则EditText功能正常 我一辈子都搞不清楚这里到底出
public class MainActivity extends Activity {
private boolean unregistered = false;
private Spinner location, time;
private Button submit;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText pin = (EditText) findViewById(R.id.pfp_pin);
pin.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(debugMode) System.out.println("In onKeyListener for PIN");
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER)) {
return true;
}
return false;
}
public int getInputType() {
return InputType.TYPE_CLASS_PHONE;
}
});
pin.setTransformationMethod(new PasswordTransformationMethod());
pin.requestFocus();
location = (Spinner) findViewById(R.id.pfp_location);
ArrayAdapter<CharSequence> loc_adapter = ArrayAdapter.createFromResource(
this, R.array.pfp_locs, android.R.layout.simple_spinner_item);
loc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
location.setAdapter(loc_adapter);
location.setOnItemSelectedListener(new LocOnItemSelectedListener());
time = (Spinner) findViewById(R.id.pfp_time);
ArrayAdapter<CharSequence> time_adapter = ArrayAdapter.createFromResource(
this, R.array.pfp_times, android.R.layout.simple_spinner_item);
time_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
time.setAdapter(time_adapter);
time.setOnItemSelectedListener(new TimeOnItemSelectedListener());
submit = (Button) findViewById(R.id.pfp_submit);
submit.setOnClickListener(new SubmitOnClickListener());
}
公共类MainActivity扩展活动{
私有布尔值未注册=false;
私人微调器位置、时间;
私人按钮提交;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText引脚=(EditText)findViewById(R.id.pfp_引脚);
setOnKeyListener(新的OnKeyListener(){
公共布尔onKey(视图v、int keyCode、KeyEvent事件){
if(debugMode)System.out.println(“In onKeyListener for PIN”);
//如果事件是“回车”按钮上的按键按下事件
if((event.getAction()==KeyEvent.ACTION\u向下)&&
(keyCode==KeyEvent.keyCode\u ENTER)){
返回true;
}
返回false;
}
public int getInputType(){
返回InputType.TYPE\u CLASS\u手机;
}
});
setTransformationMethod(新密码TransformationMethod());
pin.requestFocus();
位置=(微调器)findViewById(R.id.pfp_位置);
ArrayAdapter loc_adapter=ArrayAdapter.createFromResource(
这个,R.array.pfp_locs,android.R.layout.simple_spinner_item);
loc_adapter.setDropDownViewResource(android.R.layout.simple_微调器_下拉项);
位置。设置适配器(loc_适配器);
setOnItemSelectedListener(新的LocOnItemSelectedListener());
时间=(微调器)findViewById(R.id.pfp_时间);
ArrayAdapter time_adapter=ArrayAdapter.createFromResource(
这个,R.array.pfp_times,android.R.layout.simple_spinner_item);
time_adapter.setDropDownViewResource(android.R.layout.simple_微调器_下拉项);
设置适配器(时间适配器);
setOnItemSelectedListener(新的TimeOnItemSelectedListener());
提交=(按钮)findviewbyd(R.id.pfp_提交);
submit.setOnClickListener(新SubmitOnClickListener());
}
在那里,我尝试强制焦点、密码屏蔽和电话输入类型作为第一个措施,看看是否可以修复。这些不会改变任何行为,可以忽略,因为问题开始时它们不存在
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<ImageView
android:maxHeight="88sp"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:src="@drawable/header" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content"/>
<TextView android:id="@+id/pfp_pin_title"
android:text="@string/pfp_pin_title"
android:paddingLeft="14dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></TextView>
<EditText android:id="@+id/pfp_pin"
android:text=""
android:password="true"
android:singleLine="true"
android:inputType="phone"
android:linksClickable="false"
android:imeOptions="actionDone"
android:autoLink="none"
android:nextFocusUp="@+id/pfp_time"
android:layout_gravity="top"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
<TextView android:id="@+id/pfp_loc_label"
android:text="@string/pfp_loc_label"
android:paddingLeft="14dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/pfp_location"
android:prompt="@string/pfp_location_s"
android:layout_marginBottom="5dp"></Spinner>
<TextView android:id="@+id/pbp_time_label"
android:layout_height="wrap_content"
android:text="@string/pfp_time_label"
android:paddingLeft="14dip"
android:layout_width="fill_parent"></TextView>
<Spinner android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/pfp_time"
android:prompt="@string/pfp_time_s"
android:layout_marginBottom="25dp"></Spinner>
<Button android:layout_width="wrap_content"
android:id="@+id/pfp_submit"
android:text="@string/pfp_submit_s"
android:layout_height="65dp"
android:nextFocusDown="@+id/pfp_pin"
android:layout_gravity="center_horizontal"></Button>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxHeight="50sp"
android:scaleType="centerInside"
android:adjustViewBounds="true"
android:src="@drawable/powered_by_reversed" />
我认为这是一个bug。我在设置时遇到了与2.3.3、2.3.4和NookColor 1.20相同的问题
android:inputType="number"
它显示手机软键盘,而不是数字软键盘