我正在做一个项目来从资产或 sdcard 中的文本文件中填充微调器。我的代码是
BufferedReader in = new BufferedReader(new FileReader("product.txt"));
String line = in.readLine();
int index = 0;
while (line != null) {
str[index++] = line;
line = in.readLine();
}
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, str);
spinner.setAdapter(adapter);
和 main.xml
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
谁能帮我解决这个问题?提前致谢