ArrayList<String> al = new ArrayList<String>();
Cursor c = database.query("remedies", new String[] { "remedy" },
"d_id=?", new String[] { "" + index }, null, null, null);
while (c.moveToNext()) {
al.add(c.getString(0));
}
c.close();
TextView[] tv = new TextView[al.size()];
for (int i = 0; i < al.size(); i++) {
tv[i].setText(al.get(i));
}
我的日志猫:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ayurvedicapp/com.example.ayurvedichomecure.Remedies}:
java.lang.NullPointerException
Exception at: tv[i].setText(al.get(i));
请给我解决方案