0

スピナーがフォーカスを取得したときに、スピナーのオプションを表示したいと思います。問題は、スピナーを無視して、他のテキストビューにフォーカスジャンプすることです。

これはxmlコードです:

        <LinearLayout>
            <TextView
                android:id="@+id/lbTratamento"
                android:text="@string/lbTratamento"
                style="@style/label_padrao" />
            <EditText
                android:id="@+id/txtTratamento"
                android:layout_weight="2"
                style="@style/txt_padrao"
                android:nextFocusDown="@+id/spnTipo" />
            <TextView
                android:id="@+id/lbTipo"
                 android:text="@string/lbTipo"
                style="@style/label_padrao" />
            <Spinner
                android:id="@+id/spnTipo"
                style="@style/spinner_padrao" 
                android:layout_width="150dp"   />

        </LinearLayout>

        <LinearLayout>
            <TextView
                android:id="@+id/lbPalavraChave"
                 android:text="@string/lbPalavraChave"
                style="@style/label_padrao" />
            <EditText
                android:id="@+id/txtPalavraChave"
                android:layout_weight="2"
                style="@style/txt_padrao" 
                android:nextFocusDown="@+id/spnSexo"/>
            <TextView
                android:id="@+id/lbSexo"
                 android:text="@string/lbSexo"
                style="@style/label_padrao" />
            <Spinner
                android:id="@+id/spnSexo"
                style="@style/spinner_padrao" 
                android:layout_width="150dp" 
                android:focusable="true"
                android:focusableInTouchMode="true" />  
        </LinearLayout>

xmlプロパティでそれを行うことは可能ですか?

ありがとう!

4

2 に答える 2

1

イベント OnCreate 内に、次のように記述します。

Spinner spnSexo = (Spinner) findViewById(R.id.spnSexo);
final String[] sexos = new String[]{"Male", "Female"};
ArrayAdapter<String> adSexo = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, sexos);
adSexo.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnSexo.setAdapter(adSexo);

楽しんで...

于 2012-04-24T12:39:30.983 に答える
0

このファイルに基づいて、あなたが何をしたいのか本当にわかりません。

私はいくつかのコメントがあります:

  • レイアウト幅を単位で設定することは避けてください。トラブルになるだけです。システムに幅を設定させます。可能な限り、wrap_content を使用する必要があります。
  • Spinner で focusable または focusableInTouchMode を設定する必要はありません。
  • nextFocusDown 属性を削除して、問題が解決したかどうかを確認してください。
  • このファイルは、ウィンドウに 2 つのレイアウトがあり、ラベル、テキスト入力フィールド、およびスピナーが混在していることを示しています。うまくいくようです。あなたはそれが何をすることを期待していますか?
于 2012-03-02T23:50:22.050 に答える