|
|
|
Android : โหลดข้อมูล json จาก web service มาแล้วครับ แต่ข้อมูลไม่ขึ้นในลิสวิวครับ |
|
|
|
|
|
|
|
ช่วยหน่อยครับโปรเจคจบผม ไม่มีใครช่วยจริงๆ T T
Code (Android-Java)
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = (LinearLayout)inflater.inflate(R.layout.layout_items_hot, container, false);
scrollView = (ScrollView)rootView.findViewById(R.id.scrollview);
ArrayList<Botanical> botanicals = (ArrayList<Botanical>)FilesUtil.getBotanicalContainer(getActivity()).botanicals;
items = (LinearLayout)rootView.findViewById(R.id.items_list);
Log.e("1", "11111111111111111111111111111111111111111");
url="http://rmfl.nagasoftware.com/api/plant_by_season.php?lang_code=2&season_id=1";
//connect json
JsonArrayRequest plantReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.e(TAG, response.toString());
//hidePDialog();
Log.e("2", "2222222222222222222222222222222222222222222");
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
Log.e("3", "3333333333333333333333333333333");
JSONObject obj = response.getJSONObject(i);
RelativeLayout item = (RelativeLayout)inflater.inflate(R.layout.layout_item_hot, null);
((TextView)item.findViewById(R.id.item_title)).setText("name");
((TextView)item.findViewById(R.id.item_subtitle)).setText("scientific_name");
FontsUtil.setFont((TextView)item.findViewById(R.id.item_title), FontsUtil.FONT_BOLD);
FontsUtil.setFont((TextView)item.findViewById(R.id.item_subtitle), FontsUtil.FONT_NORMAL);
StringBuffer thumbnail = new StringBuffer();
//thumbnail.append(filePath);
thumbnail.append("thumbnail");
Log.e("4", "44444444444444444444444444444");
try{
Drawable d = Drawable.createFromStream(getActivity().getAssets().open("thumbnail"), null);
Picasso.with(getActivity())
.load(thumbnail.toString())
.placeholder(d)
.into((ImageView)item.findViewById(R.id.item_image));
}
catch(Exception e)
{
//e.printStackTrace();
}
// item.setOnClickListener(new OnClickListener() {
//
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// MainActivity main = (MainActivity)getActivity();
// main.setBotanical(b);
// main.pushPageSeq();
// main.displayView(MainActivity.VIEW_BOTANICAL_DETAIL);
// top = scrollView.getScrollY();
// }
// });
items.addView(item);
} catch (JSONException e) {
e.printStackTrace();
}
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
//adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("2", "1212121212121212121");
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(plantReq);
Tag : Mobile, Android, JAVA
|
|
|
|
|
|
Date :
2015-12-07 00:50:06 |
By :
lekkungza1 |
View :
1099 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันออกแบบนี้ครับ
|
|
|
|
|
Date :
2015-12-07 00:54:29 |
By :
lekkungza1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เกือบได้แล้วนี่ครับ ที่เหลือน่าจะเหลือแค่ Mapping ตัว Data กับ Item ใน ListView ครับ
|
|
|
|
|
Date :
2015-12-08 09:39:34 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับผม
|
|
|
|
|
Date :
2015-12-15 12:48:36 |
By :
lekkungza1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
วาวป์ได้แล้ว
|
|
|
|
|
Date :
2015-12-15 14:48:04 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|