|
|
|
Android: setAdapter spinner จาก json ไม่ได้ ครับ รบกวนช่วยชี้แนะที |
|
|
|
|
|
|
|
ต้องการ setAdapter ให้ spinner โดยโชว์ค่า province_name อ่ะครับ แต่ติดตรง new Arrayadapter มัน error province_name ครับ
Code (Android-Java)
poster.doPost(data, new Handler( ){
public void handleMessage(android.os.Message msg){
switch(msg.what){
case MyHttpPost.HTTP_POST_ERROR:
//respone_username.setText((String)msg.obj);
break;
case MyHttpPost.HTTP_POST_OK:
String response = (String)msg.obj;
Toast.makeText(context, response, Toast.LENGTH_LONG).show();
try {
JSONArray object = new JSONArray(response);
//ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
//HashMap<String, String> map;
for(int i = 0; i < object.length(); i++){
JSONObject c = object.getJSONObject(i);
String province_id = c.getString("PROVINCE_ID");
String province_name = c.getString("PROVINCE_NAME");
Toast.makeText(context, province_id + ":"+ province_name, Toast.LENGTH_LONG).show();
}
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,province_name);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_province.setAdapter(dataAdapter);
} catch (JSONException e) {
Toast.makeText(context, "Unable to convert to Json", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}
});
Tag : Mobile, MySQL, Android, JAVA
|
|
|
|
|
|
Date :
2013-06-16 14:41:09 |
By :
littlemonkeyz |
View :
1088 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Line ไหนครับ
|
|
|
|
|
Date :
2013-06-16 15:18:07 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line ที่ 28 อ่ะครับ
|
|
|
|
|
Date :
2013-06-16 15:25:58 |
By :
littlemonkeyz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|