如何在领域java中完成类似的查询,就像在这个问题中提到的那样: how do I query sql for a latest record date for each user 因为在获取查询时,似乎领域缺少group by方法
这是我的RealmObject:
Button button = (Button) findViewById(R.id.yourButton);
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// adjust the scale and duration values according to your needs
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.animate().scaleX(2).scaleY(2).setDuration(2000);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
v.animate().scaleX(1).scaleY(1).setDuration(2000);
}
return false;
}
});
这代表用户:
public class Memo extends RealmObject {
@Ignore
public static final int SENT = 1;
@Ignore
public static final int UNREAD = 2;
@Ignore
public static final int READ = 3;
@Ignore
public static final int PENDING = 4;
private static final String TAG = Memo.class.getName();
@PrimaryKey
public String id = "";
@Index
public String connection = "";
public String subject = "";
public String body = "";
public int status = 0;
public Date date;
public Boolean sentByMe = false;
public String remoteId = "";
public Boolean isFile = false;
public String filepath = "";
}
答案 0 :(得分:1)
RealmResults<Memo> latestMemos = realm.where(Memo.class)
.findAllSorted("date", Sort.DESCENDING)
.distinct("connection");