简体   繁体   English

Android App可在Debug模式下运行,但不能在Run模式下运行

[英]Android App works in Debug Mode, but not in Run mode

I have gone through the similar questions asked before, but the scarce responses are not helpful. 我已经回答过类似的问题,但是稀缺的回答没有帮助。 I am using the Volley Library to populate JSON in a Recycler View. 我正在使用Volley Library在Recycler View中填充JSON。 Here is the logcat: Referring to other SO questions, I have found Failed to set EGL_SWAP_BEHAVIOR on surface 0xb3ffe0e0, error=EGL_SUCCESS is not a problem. 这是日志: 参考其他SO问题,我发现无法在表面0xb3ffe0e0上设置EGL_SWAP_BEHAVIOR,错误= EGL_SUCCESS没问题。

Here is the Android Studio Project- https://github.com/sanke-t/Legistify 这是Android Studio项目-https ://github.com/sanke-t/Legistify

I saw your code on github. 我在github上看到了您的代码。

JsonArrayRequest fetch = new JsonArrayRequest(Request.Method.GET, url1.toString(), null, new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        try {
                            for (int i=0;i<response.length();i++)
                            {
                                JSONObject random = response.getJSONObject(i);
                                Lawyer l=new Lawyer();
                                l.setName(random.getString("name"));
                                l.setAddress(random.getString("addr"));
                                l.setPhone(random.getString("phonenum"));
                                l.setField(random.getString("lawfield"));
                                List.add(l);
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        error.printStackTrace();
                    }
                });
                queue.add(fetch);
                r=(RecyclerView)findViewById(R.id.rv);
                r.setLayoutManager(new LinearLayoutManager(this));
                adapter=new Adapter(getApplicationContext(),List);
                r.setAdapter(adapter);

Have you tried setting the adapter for your listview inside onResponse() method inside JsonArrayRequest. 您是否尝试过在JsonArrayRequest的onResponse()方法中为列表视图设置适配器。

public void onResponse(JSONArray response) {
                try {
                    for (int i=0;i<response.length();i++)
                    {
                        JSONObject random = response.getJSONObject(i);
                        Lawyer l=new Lawyer();
                        l.setName(random.getString("name"));
                        l.setAddress(random.getString("addr"));
                        l.setPhone(random.getString("phonenum"));
                        l.setField(random.getString("lawfield"));
                        List.add(l);
                    }
                    r=(RecyclerView)findViewById(R.id.rv);
        r.setLayoutManager(new LinearLayoutManager(this));
        adapter=new Adapter(getApplicationContext(),List);
        r.setAdapter(adapter);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 应用程序在调试模式下完美运行,但在运行模式下冻结 Java - Android app works perfectly in Debug mode but Freeze up in Run mode Java Firebase 实时在调试模式下工作,而不是在运行应用程序模式下工作 - Firebase Realtime works in Debug mode not in Run App mode 为什么我的(android)phonegap应用程序可以在调试模式下工作,而不能在发布模式下工作? - Why my (android) phonegap app works on debug mode but not on release mode? 应用程序适用于调试步进,但不适用于正常调试或运行模式 - App works on debug stepping but not on normal debug or run mode Android App在DEBUG模式下运作良好,但在RUN模式下却无法运作 - Android App working well with DEBUG mode, but not with RUN mode 应用程序在调试模式下工作,但在发布模式下不工作 - App works on Debug mode, but not work on Release mode Android App在调试中工作,但在发布模式下不起作用 - Android App works in debug but doesn't work in release mode 使用GSON的Android应用程序在调试模式下工作,但在运行已签名的apk时则不行 - Android app with GSON works in debug mode, but not when running signed apk Android应用程序可在WiFi上,在调试模式下或在模拟器上(而不是在蜂窝网络上)运行 - Android app works on WiFi, in debug mode, or on emulator, not on cell network 在没有广告的调试模式下运行 android studio 应用程序? - Run android studio app in debug mode without ads?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM