我可以使用类似的东西:
.forEach(System.out::print)
Run Code Online (Sandbox Code Playgroud)
打印我的列表项,但如果我在打印前有其他操作要做,我不能使用它:
mylist.replaceAll(s -> s.toUpperCase()).forEach(System.out::print)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:无法取消引用void
如何and
使用Realm 创建操作?
示例我有一个日期和月份的对象,我想检查这两个字段值.
就像是 :
RealmResults<Event> toEdit = realm.where(Event.class)
.equalTo("day", day)
.and
.equalTo("month", month)
.findAll();
Run Code Online (Sandbox Code Playgroud)
但据我所知,没有and
运营商.
谢谢
我的代码是:
if(myfile.exists()) {
try {
FileOutputStream fOut = new FileOutputStream(myfile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
for (LatLng item : markerArrayList) {
myOutWriter.append(item.toString());
}
myOutWriter.append("\n\n");
myOutWriter.close();
fOut.close();
Toast.makeText(getBaseContext(), "Done writing ", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用时myOutWriter.append
,真正发生的是每次我写入文件时,它都会覆盖以前的内容.
我从服务器获得的Json是:
{
"data" : [
{ "id":1, "url": "http://example.com/image1" },
{ "id":2, "url": "http://example.com/image2" },
{ "id":3, "url": "http://example.com/image3" }
]
}
Run Code Online (Sandbox Code Playgroud)
我用于映射的类是
public class Repository {
private List<Event> events;
}
Run Code Online (Sandbox Code Playgroud)
虽然我从改造中获得了成功,但我无法将其映射到我的对象.我也Event
有int id和String url的类.
我正在尝试一个简单的示例,例如使用a TextView
并将其从屏幕宽度的0%转换为100%
代码是:
anim0 = ObjectAnimator.ofFloat(textViewId00, "translationX", -120f, 480f);
Run Code Online (Sandbox Code Playgroud)
480f是我的屏幕宽度。
我想要的是接下来的N次(对于我的示例,n = 5)在开始之前添加延迟。
我试图在setStartDelay()
方法上添加延迟,onAnimationRepeat
但是没有效果。
我的代码是:
textViewId00 = (TextView) findViewById(R.id.textViewId00);
anim0 = ObjectAnimator.ofFloat(textViewId00, "translationX", -120f, 480f);
anim0.setDuration(2000);
anim0.setRepeatCount(5);
anim0.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
Log.i(TAG, "anim0 onAnimationStart ");
textViewId00.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
Log.i(TAG, "anim0 onAnimationEND " );
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
Log.i(TAG, "anim0 onAnimation REPEAT " );
anim0.setStartDelay(14000);
} …
Run Code Online (Sandbox Code Playgroud)