0
回答
Android litepal 建表不成功 总是提示LitePal.getDatabase();错误
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

代码段如下

LitePal.getDatabase();
        
        //设置横向滚动
        RlList.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.HORIZONTAL));
 
        //volley方法
        Volleyjiexi();
    }

    public void tianjia(String biaoti, String jieshao, String zuozhe, String neirong) {
        //建立数据库
        Poem poem = new Poem();
        poem.setBiaoti(biaoti);
        poem.setZuozhe(jieshao);
        poem.setJieshao(zuozhe);
        poem.setNeirong(neirong);
        poem.save();
        //查询第一条语句
//                Poem fristpoem= DataSupport.findFirst(Poem.class);
//                Toast.makeText(MainActivity.this, ""+fristpoem.toString(), Toast.LENGTH_SHORT).show();

    }

    //volley解析
    public void Volleyjiexi() {
        //volley请求
        queue = Volley.newRequestQueue(this);
        objectRequest = new JsonObjectRequest(url, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject jsonObject) {
                //gson解析
                Gson gson = new Gson();
                Dailybean dailybean = gson.fromJson(String.valueOf(jsonObject), Dailybean.class);
                //chulibiaoti
                String biaoti = xiugai(dailybean.getResult().getBiaoti().toString());
                TvBiaoti.setText(biaoti);
                TvAuthor.setText(dailybean.getResult().getZuozhe().toString());
                TvNote.setText(dailybean.getResult().getJieshao().toString());
                list = new ArrayList();
                String neirong = dailybean.getResult().getNeirong().toString();
//                tianjia(dailybean.getResult().getBiaoti().toString(),dailybean.getResult().getZuozhe().toString(),
//                        dailybean.getResult().getJieshao().toString(),dailybean.getResult().getNeirong().toString());
                //去掉文本中的【】 {} ()符号中的内容
                String s = xiugai(neirong).trim();

                //将文本按照标点符号分为数组
                String[] temp = s.split(",|。|;|?");
                for (int i = 0; i < temp.length; i++) {
                    list.add(temp[i]);
//                    Toast.makeText(MainActivity.this, "" + temp[i], Toast.LENGTH_SHORT).show();
                }
                Radapter = new Recycleradapter(getApplicationContext(), list);
                RlList.setAdapter(Radapter);

                avi.hide();
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        });
        objectRequest.setTag("Tag1");
        queue.add(objectRequest);


    }
<无标签>
举报
哎嘿嘿
发帖于9个月前 0回/413阅
顶部