0
說我的ArrayList中有150項我想告訴分頁 所以我的時間 怎麼只顯示前10項第一本有沒有辦法在分頁中顯示數組列表項?
arraylist.subList(0,10);
嘗試,但它不工作
編輯: 我的ArrayList中從由JSON數組的樣子:
ArrayList<HashMap<String, String>> arraylist;
UserFunctions userFunction = new UserFunctions();
JSONObject whatAreYouLooking = userFunction.getTopicsList();
arraylist = new ArrayList<HashMap<String, String>>();
try {
if (whatAreYouLooking.getString(KEY_SUCCESS) != null) {
String search_res = whatAreYouLooking.getString(KEY_SUCCESS);
if(Integer.parseInt(search_res) == 1){
jsonarray = whatAreYouLooking.getJSONArray("result");
JSONArray jsonWhatAreYouLookingArray = new JSONArray(whatAreYouLooking.optString("result"));
for (int w = 0; w < jsonWhatAreYouLookingArray.length(); w++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject jsonLookingObject = jsonWhatAreYouLookingArray.getJSONObject(w);
map.put("topicID", jsonLookingObject.getString("topicID"));
map.put("Name", jsonLookingObject.getString("Name"));
map.put("Phone",jsonLookingObject.getString("Phone"));
arraylist.add(map);
listview = (ListView) view.findViewById(R.id.listview);
adapter = new ListViewAdapter(this.getActivity(), arraylist);
listview.setAdapter(adapter);
}
}else{
}
}else{
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
給予好評,請...... –