- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Hello. There is a table from which data is displayed in ListView by position. Everything works great. But if there are spaces in the table, then this becomes a problem. How can I switch to the desired activity by _id in the table, and not by position? I ask for help, I will be very grateful. Thank you all very much! Below is my code:
This is my code MainActivity.java
this.listView = findViewById(R.id.listView);
DatabaseAccess databaseAccess = DatabaseAccess.getInstance(this);
databaseAccess.open();
List<String> quotes = databaseAccess.getQuotes();
databaseAccess.close();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, quotes);
this.listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if(id==0){
Intent myintent = new
Intent(view.getContext(),MosObl.class);
startActivityForResult(myintent,0);
}
if(id==1){
Intent myintent = new
Intent(view.getContext(),Arhangelsk.class);
startActivityForResult(myintent,1);
}
if(id==2){
Intent myintent = new
Intent(view.getContext(),Astrahan.class);
startActivityForResult(myintent,2);
}
This is my code DatabasesAccess.java
public List<String> getQuotes() {
List<String> list = new ArrayList<>();
Cursor cursor = database.rawQuery("SELECT * FROM regiones where izbrannoe = 1", null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
list.add(cursor.getString(0));
cursor.moveToNext();
}
cursor.close();
return list;
}
最佳答案
通过单击项目的位置(这是您能够直接获取的唯一内容),您可以使用以下方法从列表“quotes”中获取报价:
final String desiredQuote = quotes.get(position);
然后,向您的数据库发出请求,您将能够获得所需的 ID。像这样的东西:
final Cursor cursor = database.rawQuery("SELECT _id FROM regiones where izbrannoe = 1 AND quote=?",new String [] {desiredQuote});
这就是你要找的吗?
关于java - 如何不按位置而是按sqlite表中的_id切换到新的Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58283844/
这个问题已经有答案了: node.js mongodb .. the (immutable) field '_id' was found to have been altered (5 个回答) 已关
db.books.update({bookId:"123461"},{$set:{"bookPrice":"6.23"}}) 我收到错误: update { q: { bookId: "1234
使用典型的 _id 列并连接表并在创建游标时选择所有列,将导致包含多个 _id 列的游标。 要访问特定的 _id 列,则需要使用实际偏移量,而不是列名。 使用硬编码的偏移量可能会有问题,它使代码更难阅
我使用 ASP .NET MVC4 WebAPI 并且我有一些类(class) public class Recipe { [BsonId] [BsonRepresentation(B
我正在尝试为 MongoDB 中的 _id 字段使用 UUID。 我有一个包装器结构来保存我的记录,如下所示: type mongoWrapper struct { ID uuid.
在 CodeIgniter 的 MongoDB 中进行更新时,出现以下错误: Type: MongoWriteConcernException Message: localhost:27017: Af
我想启动分片。如您所知,分片键非常重要。我发现,MongoDB doesn't ensure unique _id field values when using a shard key other
当我在ES 6.3.2上使用以下内容进行搜索时,没有问题: {“查询”:{“match_phrase_prefix”:{“_ id”:“ZX-bLmsBFOiwdS-Iwr24”}}} 但是,当我在E
我想运行以下查询: Group.find({program: {$in: [...]}}).lean().select('_id') 然后不得到回复: [{_id: ...}, {_id: ...},
我已将我的 ID 重命名为 _id,但仍然得到列“_id”不存在 ...我错过了什么吗? MyDatabaseelper.java public class MyDatabaseHelper exte
所以当我使用 int location = cursor.getColumnIndex(_ID) 它总是返回零,尽管 long locationId = cursor.getlong(getColum
我有一个看起来像这样的路径 path: '/speakers/singleDetails/:_id' 和一个具有这样的字段的架构 speakerId: { type: String,
userSchema={ username: { type: String, required: true, unique: true }, password: {
我正在尝试使用 updateOne 方法更新文档: UpdateResult r = coll.updateOne( eq("_id", id), this.getMapper().m
例如: 我有一个收藏“故事”其中每个文档的形式为: { '_id': 'story': } 现在每当我有一个故事时,如果它已经存在于“故事”中,我想要它的“_id”,否则插入一个带有“故事
这是我的 users.js(routes) for(var zz =0;zz < d.length; zz++){ temp
我在 Nodejs 中有一个数组,其中包含需要检索的 mongoDB 文档的 document _id 值。因此,我需要以这样的方式查询 mongoDB,使其返回 _id 值与我想要传入查询的数组中至
正如您在 NodeJS 代码中看到的那样,我正在从 URL 中提供的 Postman token 中获取用户,但我正在努力从给定的 token 号中取回 _id 属性。我想要的是decoded._id
我是 Android 新手。我有一个 SQLite 后端,其中每一行都是唯一的(想想一个人)。然后,我在每个人的 ListView 中显示这些数据。单击 ListView 项时,它将转到 subvie
他们是否都引用了联系人的同一个唯一 contactId? 最佳答案 他们应该这样做,但不能保证联系人是否已同步或聚合。您可能想尝试使用 LOOKUP_KEY相反。 关于Android dev : Ph
我是一名优秀的程序员,十分优秀!