(위에서), 그런 다음 그에 따라 어댑터를 설정할 수 있습니다
EditText editText = (EditText) findViewById(R.id.edit_text_id);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO use this to set your new string value
editValue = s; // this won't work directly, but it is the idea of what you want to accomplish
}
}
텍스트의 변화를 확인하기 위해 리스너를 설정해야합니다 구현해야
당신은 spinner
에 Adapter
설정이 필요하고, 입력 텍스트에 따라
final Spinner spinner = (Spinner) findViewById(R.id.spinner);
final EditText editText = (EditText) findViewById(R.id.editText1);
Button button = (Button) findViewById(R.id.submit);
final List<String> stringList = new ArrayList<String>();
final ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(ListEditActivity.this,
android.R.layout.simple_spinner_item);
spinner.setAdapter(spinnerAdapter);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// clear the array list
stringList.clear();
// add the default item at first
stringList.add("FIRST ITEM");
if (editText.getText() != null && editText.getText().length() > 0) {
String input = editText.getText().toString();
if (input.toLowerCase().equalsIgnoreCase("one")) {
// add the spinner items for this input
stringList.add("ONE");
} else if (input.toLowerCase().equalsIgnoreCase("two")) {
// add the spinner items for this input
stringList.add("TWO");
} else {
// show dialog that invalid input
return;
}
// update the adapter with new data
spinnerAdapter.clear();
// adding the item will also notify the spinner to refresh the list
spinnerAdapter.addAll(stringList);
}
}
});
Adapter
는 감사의 데이터를 변경합니다. 좋은 해결책. – AndreaF