如何将自定义适配器字段与数据库字段相等

时间:2016-12-17 07:16:27

标签: java android android-sqlite

我只是想从数据库获取接收者ID到这里并且与自定义列表接收者id重力集

相等
if(customList.getReceiverid( ) .equals (database.getreceiverid(pos))) {
    viewHolder.message.setGravity(Gravity.LEFT);
    viewHolder.time.setGravity(Gravity.LEFT);
}
else
{
    viewHolder.message.setGravity(Gravity.RIGHT);
    viewHolder.time.setGravity(Gravity.RIGHT);
}

我的数据库代码如下

public ArrayList<CustomList> getreceiverid(String receiverid) {
    ArrayList<CustomList> array_list = new ArrayList<>();


    SQLiteDatabase db = this.getReadableDatabase();
    Cursor res = db.rawQuery("select * from " + MESSAGE_TABLE_NAME, null);
    res.moveToFirst();

    while (res.isAfterLast() == false) {
        CustomList item = new CustomList(" type ", " senderid ", " receiverid ", " message ", " time ");
        ContentValues contentValues = new ContentValues();
        item.getReceiverid();
        contentValues.put(RECEIVERID, receiverid);


        res.moveToNext();
    }
    return array_list;
}

0 个答案:

没有答案