【发布时间】:2011-03-01 14:06:38
【问题描述】:
- 我有一个 xml 布局文件,其中包含一些小部件,包括 Spinner
- 我想在微调器中显示一个字符串列表,该列表是在运行时作为函数的结果生成的,因此它不能在 arrays.xml 中。
我试过了:
String[] SpinnerItems = GetMyCustomItems();
((Spinner)findViewById(R.id.MySpinner)).setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1,SpinnerItems));
但这会使我的应用程序崩溃。
实现此目的的正确方法是什么?
【问题讨论】:
-
你能把它在 logcat 中打印出来的错误堆栈贴出来吗?
标签: java android arrays spinner