【发布时间】:2012-01-13 14:26:03
【问题描述】:
你好(对不起)
我厌倦了从 sqlitele 填充微调器,它工作正常,但我的表看起来像:
_id |姓名 |时间 | ....
_id: 是自增号总是唯一的 姓名:是人名,在此表中的多行重复
我想将这一行中的所有名称都放入微调器,但 uniq 没有重复项。 我现在怎么样了:
私人无效 updateSpiner(){ Spinner nameSpinner = (Spinner) findViewById(R.id.spinMena);
Cursor nameCursor = db.getNames();
startManagingCursor(nameCursor);
String[] from = new String[]{"Name"};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter nameAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, nameCursor, from, to);
nameSpinner.setAdapter(nameAdapter);
}
这是我获取数据的方式:
public Cursor getNames(){
final String KEY_TITLE = "Name";
final String KEY_ROWID = "_id";
return database.query("plan", new String[] {KEY_ROWID, KEY_TITLE}, null, null, null, null, null);
}
有人可以向我解释为什么我还需要为此获取 _id 行,我现在还在使用 Java,我不明白为什么需要它,除非我不这样做,它会抱怨那里没有_id。
但它没有在第一种方法中使用,我只从中获取名称...因为 _id 我不能在查询 DISTINCT = true 中使用,因为它仍然返回所有行,因为 _id 对于每一行都是唯一的..
有人可以帮我把头绕过去吗?我不想做单独的表什么的..
谢谢, 弗拉德
【问题讨论】:
-
您的表需要不同的名称?
标签: java android spinner sqlplus