ローカルホストでこのコードを使用してアップロードしたときにlistViewを表示しましたが、ListViewに何も表示されません。それで、私は何をしたのですか?通常、私はすべてのデータをデータベースに保存しますが、画面は空です。JSONエラーを使用しているAndroid:「データの解析中にエラーが発生しました。org.json.JSONException:値」
private ListView listView;
public static final String URL="http://gabes.comlu.com/Base_Controle/getAllEmp.php";
// static String TAG_JSON_ARRAY="";
private String JSON_STRING;
static JSONObject result = null;
public static final String TAG_JSON_ARRAY = "result";
private void showEmployee(){
JSONObject jsonObject = null;
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String, String>>();
try {
jsonObject = new JSONObject(JSON_STRING);
JSONArray result = jsonObject.getJSONArray(TAG_JSON_ARRAY);
for(int i = 0; i<result.length(); i++){
JSONObject jo = result.getJSONObject(i);
String nom1 = jo.getString("nom");
String tele1 = jo.getString("tele");
String grade1 = jo.getString("grade");
String image1 = jo.getString("image");
String site1 = jo.getString("site");
String email1 = jo.getString("email");
HashMap<String,String> employees = new HashMap<>();
// employees.put("Type",type);
employees.put("log",nom1);
employees.put("a",tele1);
employees.put("pre",grade1);
employees.put("d",image1);
employees.put("c",site1);
employees.put("b", email1);
list.add(employees);
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
ListAdapter adapter = new SimpleAdapter(
getActivity(), list, R.layout.list_item1,
new String[]{"log","pre","a","b","c","d"},
new int[]{R.id.id, R.id.name,R.id.a});
listView.setAdapter(adapter);
}
はあなたを投稿logcatとjson – Mohit
jsonとスタックトレースを投稿してください! –
あなたはウェブからjsonを手に入れませんでしたか? –