【问题标题】:android json to listviewandroid json到listview
【发布时间】:2011-02-05 21:06:36
【问题描述】:

我使用 android 和 JSON。到目前为止,我可以在arraylist中设置ID。错误将在“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();
             }

    }

【问题讨论】:

  • eclipse没有错误。只有当我把它放在安卓手机上时,我的程序才会自动关闭
  • 您能否打印出“响应”的样子以帮助我们更好地调试它。

标签: android json arraylist


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    相关资源
    最近更新 更多