我只是想从数据库获取接收者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;
}