我试图与微调器一起工作。在所选项目上,该项目将转到编辑文本。所以对于我的界面是:
例如,当用户单击KLCC(其中一个微调项目)时,它将转到位置文本视图下的编辑文本。我尝试过在互联网上找到的几个选项,似乎很好,没有错误,但是当我试图插入细节时出现了问题,这是我在看完之后的样子尝试了我刚刚尝试过的代码:
并且界面继续。我的意思是有2个图像按钮,2个名称(编辑文本和文本视图)和其他相同。在我实现微调器之前,所有工作都非常好,直到微调器开发。
(我的微调器ID是= locationspinner,我的edittext id是= edittext_location)
所以这里是代码,
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.save, container, false);
locationspinner = (Spinner)mRootView.findViewById(R.id.locationspinner);
textforspinner = (EditText)mRootView.findViewById(R.id.editText_location);listlocation.add("Bukit Bintang");
listlocation.add("Bukit Antarabangsa");
listlocation.add("Brickfields");
listlocation.add("Gombak");
listlocation.add("Jalan Chow Kit");
listlocation.add("Jalan Dang Wangi");
listlocation.add("Jalan Tun Razak");
listlocation.add("Jalan Hang Tuah");
listlocation.add("Jalan Tunku Abdul Rahman");
listlocation.add("KLCC");
listlocation.add("Kampung Baru");
listlocation.add("KL Sentral");
listlocation.add("Lowyat");
listlocation.add("Pavillion");
listlocation.add("Pasar Seni");
listlocation.add("Pudu");
listlocation.add("Shah Alam");
listlocation.add("Time Square");
listlocation.add("Wangsa Maju");
listlocation = new ArrayList<String>();
ArrayAdapter<String> adp = new ArrayAdapter<String>(this.getActivity(),R.layout.save, R.id.editText_location,listlocation);
adp.setDropDownViewResource(R.layout.save);
locationspinner.setAdapter(adp);
locationspinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
switch(arg2){
case 0:
textforspinner.setText("Value 0");
break;
case 1:
textforspinner.setText("Value 1");
break;
case 2:
textforspinner.setText("Value 2");
break;
case 3:
textforspinner.setText("Value 3");
break;
case 4:
textforspinner.setText("Value 4");
break;
case 5:
textforspinner.setText("Value 5");
break;
case 6:
textforspinner.setText("Value 6");
break;
case 7:
textforspinner.setText("Value 7");
break;
case 8:
textforspinner.setText("Value 8");
break;
case 9:
textforspinner.setText("Value 9");
break;
case 10:
textforspinner.setText("Value 10");
break;
case 11:
textforspinner.setText("Value 11");
break;
case 12:
textforspinner.setText("Value 12");
break;
case 13:
textforspinner.setText("Value 13");
break;
case 14:
textforspinner.setText("Value 14");
break;
case 15:
textforspinner.setText("Value 15");
break;
case 16:
textforspinner.setText("Value 16");
break;
case 17:
textforspinner.setText("Value 17");
break;
case 18:
textforspinner.setText("Value 18");
break;
default:
textforspinner.setText("Nothing");
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});*/
InitializeViews();
return mRootView;
}
我真的很抱歉我的问题很糟糕。非常感谢您的帮助和时间来帮助我解决问题:)
提前致谢! :d