android json 到列表视图 [英] android json to listview

查看:22
本文介绍了android json 到列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 android 和 JSON.我到此为止,但我可以在arraylist 中设置ID.错误将在json_data.getInt("ID")"

I working with android and JSON. I came so far, but I can's set the ID in the arraylist.The error will be in "json_data.getInt("ID")"

谁能帮帮我

    public void klussenlijst()
    {
ArrayList<String> results = new ArrayList<String>();
        JSONObject json_data;
        mysql client = new mysql("http://www.****************/klussen.php?actie=klussen");

        try {
            client.Execute(RequestMethod.POST);
        } catch (Exception e) {
            e.printStackTrace();
        }

        String response = client.getResponse();

        try{;
        JSONArray jArray = new JSONArray(response);
             for(int i=0;i<jArray.length();i++){
             json_data = jArray.getJSONObject(i);
             results.add(json_data.getInt("ID"),(String) json_data.get("titel").toString());
            }
             filllist();


             }
             catch(JSONException e){
                 e.printStackTrace();
             }

    }

推荐答案

不确定你的 mysql() 方法和错误处理的巨大缺失,但你确定你的项目在你的 AndroidManifest.xml 中允许 INTERNET 权限文件?在我看来,您的 getInt 不是 int.

Not sure about your mysql() method and the huge lack of error handling, but are you sure that your project has allowed for INTERNET permissions in your AndroidManifest.xml file? Sounds to me like your getInt is not an int.

这篇关于android json 到列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆