我按照如何根据所选项目更改 textview 的值的步骤,这是一段代码
public void onCreate(Bundle savedInstanceState){.......
final TextView privacyTextView = (TextView) findViewById(R.id.eventPrivacy);
privacySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View v, int position, long id3) {
final String selectedItem = parent.getItemAtPosition(position).toString();
privacyTextView.setText(selectedItem);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
清单是:
<string-array name="privacy_levels">
<item>Everyone</item>
<item>Friends of Friends</item>
<item>Friends Only</item>
<item>Customize</item>
</string-array>
我有带有值的文本视图:privacy
运行应用程序时,它会自动更改为Everyone
- 列表中的第一个 - 所以出了什么问题?!!!