Android Spinner通过键盘设置值

时间:2013-09-11 18:47:00

标签: android keyboard android-spinner

我有一个带有一些选项的Spinner菜单:地方。我希望有一个名为Custom的选项,当用户选择它时会显示一个editText并从键盘设置该位置。

我想有一个不可见的editText,当用户从spinner选择Custom时,这个字段弹出键盘来设置它。可能吗?如果没有,我可以解决我的问题吗?

提前感谢!!

---编辑我的代码---

// Array of place types
    mPlaceType = getResources().getStringArray(R.array.place_type);

    // Array of place type names
    mPlaceTypeName = getResources().getStringArray(R.array.place_type_name);

    // Creating an array adapter with an array of Place types
    // to populate the spinner
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, mPlaceTypeName);

    // Getting reference to the Spinner 
    mSprPlaceType = (Spinner) findViewById(R.id.spr_place_type);

    // Setting adapter on Spinner to set place types
    mSprPlaceType.setAdapter(adapter);

单击按钮确定后,我会检查用户的选择

int selectedPosition = mSprPlaceType.getSelectedItemPosition();
String type = mPlaceType[selectedPosition];

和string.xml

<string-array name="place_type">
        <item>restaurant</item>
        <item>cafe</item>
        <item>gas_station</item>
         <item>custom</item>
    </string-array>
    <string-array name="place_type_name">
        <item>Restaurant</item>
        <item>cafe</item>
        <item>gas_station</item>
        <item>Custom...</item>
    </string-array>

0 个答案:

没有答案