无报错 但是Android 不显示数据
androidstudio吧
全部回复
仅看楼主
level 2
数据正常打印 就是不显示
不用okhttp获取数据 自己手动初始化就可以 init()
2019年09月21日 04点09分 1
level 2
而且用用Gson解析后adapter = new CommonRecyclerAdapter<text>(this,R.layout.user_layout,userList) 也不会调用
但是 init()会调用
2019年09月21日 05点09分 3
level 8
你把getRequest放在new适配器之前,不然传进适配器userlist为空
2019年09月21日 05点09分 4
没用的,试过了
2019年09月21日 05点09分
level 2
2019年09月21日 05点09分 5
level 2
2019-09-21 14:20:18.808 10957-10957/? I/e.myapplicatio: Not late-enabling -Xcheck:jni (already on)
2019-09-21 14:20:18.849 10957-10957/? E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000
2019-09-21 14:20:18.850 10957-10957/? W/e.myapplicatio: Unexpected CPU variant for X86 using defaults: x86
2019-09-21 14:20:19.454 10957-10991/com.example.myapplication D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2019-09-21 14:20:19.440 10957-10957/com.example.myapplication W/RenderThread: type=1400 audit(0.0:69): avc: denied { write } for name="property_service" dev="tmpfs" ino=6800 scontext=u:r:untrusted_app:s0:c177,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
2019-09-21 14:20:19.455 10957-10991/com.example.myapplication W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2019-09-21 14:20:19.602 10957-10991/com.example.myapplication D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2019-09-21 14:20:19.607 10957-10991/com.example.myapplication D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2019-09-21 14:20:19.610 10957-10991/com.example.myapplication D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2019-09-21 14:20:19.814 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2019-09-21 14:20:19.814 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2019-09-21 14:20:20.163 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.163 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setHostname(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.163 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.164 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.170 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.170 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.170 10957-10957/com.example.myapplication W/e.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
2019-09-21 14:20:20.171 10957-10957/com.example.myapplication D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
2019-09-21 14:20:20.243 10957-10989/com.example.myapplication W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2019-09-21 14:20:20.247 10957-10989/com.example.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2019-09-21 14:20:20.247 10957-10989/com.example.myapplication D/EGL_emulation: eglCreateContext: 0xdf71a2a0: maj 3 min 0 rcv 3
2019-09-21 14:20:20.277 10957-10989/com.example.myapplication D/EGL_emulation: eglMakeCurrent: 0xdf71a2a0: ver 3 0 (tinfo 0xdf70f780)
2019-09-21 14:20:20.294 10957-10989/com.example.myapplication W/Gralloc3: mapper 3.x is not supported
2019-09-21 14:20:20.299 10957-10989/com.example.myapplication D/eglCodecCommon: allocate: Ask for block of size 0x1000
2019-09-21 14:20:20.299 10957-10989/com.example.myapplication D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000
2019-09-21 14:20:20.344 10957-10989/com.example.myapplication D/EGL_emulation: eglMakeCurrent: 0xdf71a2a0: ver 3 0 (tinfo 0xdf70f780)
2019-09-21 14:20:20.345 10957-10989/com.example.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
2019-09-21 14:20:20.376 10957-10993/com.example.myapplication D/调试信息: [{"id":1,"user_id":1,"task_name":"1","task_content":"1","success":0,"add_time":1,"end_time":1,"finish_id":[1,4]}]
2019年09月21日 06点09分 6
level 1
post/get是有延迟的,而程序运行速度太快,所以得到request之前被传入适配器中的是空值。即使你把request放在adapter之前也没用,并且onCreate方法只会在Activity启动时被执行一次,所以把setAdapter写在onCreate中没啥用,尤其是通过网络获取数据时
解决办法就是写个HandlerMessage,在你的post/get线程中给HandlerMessage通知,用handler来更新适配器就可以了
Handler的写法
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
view.setAdapter(adapter);
break;
}
super.handleMessage(msg);
}
};
然后在这下面加一句
handler.sendEmptyMessage(0);
2019年10月16日 18点10分 7
活用handler,你可以用它手动刷新数据或者自动刷新,也可以在网络错误时给出正确的提示
2019年10月16日 18点10分
另外,UI更新必须在主线程进行,所以你不能把setAdapter直接写在上图所示的地方,会出错
2019年10月16日 18点10分
@血v魔 感谢大佬的回答
2019年10月21日 09点10分
level 1
Ť同问大佬:
2020年03月20日 04点03分 8
Ĵ界面可以运行,就是在最后一个按钮点击时退回主页面崩溃了
2020年03月20日 04点03分
@瞭望角之星 我也想问
2020年03月23日 03点03分
level 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without..
2020年04月19日 11点04分 9
这个怎么解决啊啊啊啊啊。。。。
2020年04月19日 11点04分
level 2
你的userlist,为空,应该是在适配器之前给userlist添加数据;要不然传进adapter的就是一个空集合,什么也不会展示的
2020年04月24日 05点04分 10
level 1
我的也是
2020年06月14日 02点06分 11
level 1
2020年06月14日 02点06分 12
level 11
适配器没设置数据与刷新
2020年06月18日 03点06分 13
1