簡體   English   中英

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

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

我已經回答過類似的問題,但是稀缺的回答沒有幫助。 我正在使用Volley Library在Recycler View中填充JSON。 這是日志: 參考其他SO問題,我發現無法在表面0xb3ffe0e0上設置EGL_SWAP_BEHAVIOR,錯誤= EGL_SUCCESS沒問題。

這是Android Studio項目-https ://github.com/sanke-t/Legistify

我在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);

您是否嘗試過在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM