private List<Map<String, Object>> data;
// 加载试图布局、 loadingView = LayoutInflater.from(this).inflate( R.layout.list_page_load, null);
// 自定义适配器 public class ListViewAdapter extends BaseAdapter { int count = data.size(); public final class ListItemView {// 自定义控件集合 public TextView thread_number; public TextView thread_author; public TextView thread_time; public TextView thread_text; } public int getCount() { return count; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ListItemView listItemView = null; final int index = position; if (convertView == null) { listItemView = new ListItemView(); convertView = LayoutInflater.from(ThreadDetailsActivity.this) .inflate(R.layout.forum_threaddetails_item, null); listItemView.thread_number = (TextView) convertView .findViewById(R.id.thread_number); listItemView.thread_author = (TextView) convertView .findViewById(R.id.thread_author); listItemView.thread_time = (TextView) convertView .findViewById(R.id.thread_time); listItemView.thread_text = (TextView) convertView .findViewById(R.id.thread_text); convertView.setTag(listItemView); } else { listItemView = (ListItemView) convertView.getTag(); } listItemView.thread_number.setText((String) data.get(position).get( "thread_number")); listItemView.thread_author.setText((String) data.get(position).get( "thread_author")); listItemView.thread_time.setText((String) data.get(position).get( "thread_time")); listItemView.thread_text.setText((String) data.get(position).get( "thread_text")); return convertView; } }
public static List<Map<String, Object>> initValue(int currentPage, int pageSize) { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); for (int i = (currentPage - 1) * pageSize; i < currentPage * pageSize; i++) { HashMap<String, Object> win = new HashMap<String, Object>(); win.put("thread_number", (i+1)+"楼"); win.put("thread_author", "石狮市"); win.put("thread_time", "10-12 08:23"); win.put("thread_text", "是的南方上看的麻烦的是否将 佛说法理念方式离开的法律撒"); list.add(win); } return list; }