Android Nexus S EditText settings ignored (2.3.4)

霸气de小男生 提交于 2020-01-02 18:21:49

问题


I hadn't seen this issue until after the 2.3.4 update for the Nexus S phone.

I have a very simple application, with a main activity that loads on start of the application.

This main activity has a LinearLayout consisting of some TextViews, and EditText, a couple Spinners, and a Button.

I am now having an issue with the input to the EditText. It is supposed to come up with a soft keyboard with the phone input type. Instead it comes up with the standard alpha-numeric soft keyboard and once you start typing input, it passes this to the Google Search application, and does not fill in the EditText at all.

If I go to my settings activity and navigate back, the EditText functions properly.

I can't for the life of me figure out what is going wrong here, and am on the verge of declaring this an issue with the 2.3.4 update for the phone.

Activity code:

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()); 
}

In there I tried forcing focus, password masking, and the phone input type as first measures to see if I could fix it. These don't change any behavior and could be ignored as they were not there when the issue began.

Layout

<?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" />


回答1:


I believe it is a bug. I have the same issue with 2.3.3, 2.3.4, and NookColor 1.20 when setting

    android:inputType="number"

It displays the phone soft keyboard instead of the number soft keyboard.



来源:https://stackoverflow.com/questions/6218574/android-nexus-s-edittext-settings-ignored-2-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!