0
我想要在用戶在微調器上選擇「組合」時出現EditText對象,我該怎麼做?用戶輸入導致窗體出現
這是我一直在努力:
ground = (Spinner) findViewById(R.id.ground);
ArrayAdapter<CharSequence> groundAdapter = ArrayAdapter.createFromResource(
this, R.array.ground_array, android.R.layout.simple_spinner_item);
groundAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ground.setAdapter(groundAdapter);
ground.setOnItemSelectedListener(new GroundListener());
if(ground.getSelectedItem().toString().equalsIgnoreCase("Combination"))
{
combo.setVisibility(0);
}
的對象的EditText組合在XML文件中設置爲android:visibility="gone"
GroundListener代碼是
public class GroundListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String selected = parent.getItemAtPosition(pos).toString();
}
public void onNothingSelected(AdapterView parent)
{
// Do nothing.
}
}
「公共類GroundListener實現OnItemSelectedListener { \t公共無效onItemSelected(適配器視圖>父,瀏覽視圖,整數POS,長ID){ \t字符串選擇= parent.getItemAtPosition(POS)的ToString(); \t} \t公共無效onNothingSelected(適配器視圖父) \t { \t //什麼也不做。 \t} \t}'這就是GroundListener。對不起,應該包括在問題中。現在編輯 – Zaask
我仍然不知道該怎麼辦 – Zaask
我已經編輯了我的答案給你。 – Yahel