1
我有一组微件中的项目和他们的点击我想在EditText中显示相应的文本。我如何才能做到这一点。我想过使用开关,但它不适用于字符串。我希望有人告诉我这样做的正确方法。显示微调选项上的EditText项目
我想让EditText数组(mysuburb)根据微调项目(mystate)点击做出相应的响应。
代码: -
String[] mysuburb =new String[]{"sub1" ,"sub2","sub3","sub4","sub5","sub6"};
String[] mystate= new String[]{"NSW","Victoria","Qld","NT","WA","SA"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity(), R.layout.listrow, mystate);
// LTRadapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
state.setAdapter(adapter);
state.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,int pos, long arg3) {
// TODO Auto-generated method stub
sstate = state.getSelectedItem().toString();
/* String sub= state.getItemAtPosition(0).toString();
if(sub=="sub1")
suburb.setText("sub1") ; */
suburb.setText(arg0.getItemAtPosition(pos).toString());
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
后你的代码。 – Hariharan
你试过了什么?显示你的代码。 – SilentKiller
您是否使用Bean类对象来填充微调器?先显示代码。 – Dhaval