我想通过查询设置 TextView 的 txt,但我收到“请求索引 -1,大小为 1 错误。有人可以帮助我吗?
Cursor information = db.rawQuery("select id as _id,description from poet where _id="+Peot_ID_for_db,null);
TextView poet_info=(TextView)findViewById(R.id.Poet_info);
poet_info.setText(information.getString(information.getColumnIndex("_id")));
// poet_info.append(information.getString(information.getColumnIndex("description")));
我搜索了这个错误,但在谷歌中没有找到任何东西。我希望你能帮助我。 我的表中只有一行与此查询匹配,所以我想我不需要任何循环或类似的东西来获取所有行
最佳答案
您还没有将光标移动到该行..它会为您抛出该错误
尝试使用这个
if(information.moveToFirst())
{
do{
//Write your code here
}
while(information.moveToNext())
}
关于android - Android 中 txtview.settext 中的未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15818479/