将数据从CSV文件获取到textView

时间:2015-03-23 19:14:04

标签: java android csv textview

我有一个包含A列100个问题的CSV文件,在B列中有相应的答案,我正在尝试做的是在textView中显示问题#1然后当你点击textView或者按钮你得到答案#1,然后问题#2,回答#2 ...注意:这是我第一次在Android应用程序(新手)中使用CSV文件。 这是我的代码。

try {
            CSVReader reader = new CSVReader(new FileReader("medicallist.csv"));

            String [] row;
            while ((row = reader.readNext()) != null) {
                textView1.setText(row[1].toString());
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

我将csv文件放在raw文件夹中,然后将opencsv 2.2 jar添加到lib文件夹中。 textView中不显示任何文本。可能是什么问题?

0 个答案:

没有答案