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();
}
给予好评,请...... –