我有5个纺纱厂。为了对此做出总结。如何获得微调器选定的项目值为字符串?
这是微调在XML
<Spinner
android:id="@+id/text_interested"
android:layout_span="2"
android:layout_width="wrap_content"
android:layout_height="60px"
android:entries="@array/interestedarrays"
android:prompt="@string/interestedprompt" />
这是微调在Java中
submitbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
interested.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(
AdapterView<?> adapterView, View view,
int i, long l) {
interesting = interested.getItemAtPosition(i).toString();
}
public void onNothingSelected(
AdapterView<?> adapterView) {
}
});
}
});
说明这里:
页有一个按钮。此按钮将在按下时读取微调器中的数据。我用这个检查了输出
System.out.println(interested.getItemAtPosition(i).toString());
它给了我什么都不是空。
如何检索值并将其字符串?
我肯定,你想从每当一个按钮 – 2012-04-26 10:50:04
用户点击设置你的按钮的onClick这interested.getSelectedItem()。的toString外部和内部的onclick方法使用setOnItemSelectedListener一个微调选定的项目() ; – 2012-04-26 10:58:16
谢谢,我的错误被放在按钮监听器里面的听众,为什么没有回应 – 2012-04-26 11:18:48