Настройки Android Nexus S EditText игнорируются (2.3.4) - PullRequest
2 голосов
/ 02 июня 2011

Я не видел этой проблемы до тех пор, пока не появилось обновление 2.3.4 для телефона Nexus S.

У меня очень простое приложение с основным действием, которое загружается при запуске приложения.

У этого основного действия есть LinearLayout, состоящий из нескольких TextViews, и EditText, пары Spinners и Button.

У меня сейчас проблема с вводом в EditText. Предполагается придумать программную клавиатуру с типом ввода телефона. Вместо этого он предлагает стандартную буквенно-цифровую программную клавиатуру и, как только вы начинаете вводить текст, передает его в приложение Google Search и не заполняет EditText вообще.

Если я перехожу к своему заданию по настройкам и возвращаюсь назад, EditText работает правильно.

Я не могу понять, что здесь происходит, и я на грани объявления об этом с обновлением 2.3.4 для телефона.

Код активности:

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

Там я попытался настроить фокус, маскировку паролем и тип телефонного входа в качестве первой меры, чтобы посмотреть, смогу ли я это исправить. Они не изменяют никакого поведения и могут быть проигнорированы, поскольку их не было, когда возникла проблема.

Компоновка

<?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 Ответ

1 голос
/ 14 июля 2011

Я считаю, что это ошибка. У меня та же проблема с 2.3.3, 2.3.4 и NookColor 1.20 при установке

    android:inputType="number"

Отображает программную клавиатуру телефона вместо цифровой клавиатуры.

...