private void initUI() { mi = new MenuInflater(this); layout_body_activity = (LinearLayout) findViewById(R.id.bodylayout); img_recent_chat = (ImageView) findViewById(R.id.tab1); img_recent_chat.setOnClickListener(this); img_friend_list = (ImageView) findViewById(R.id.tab2); img_friend_list.setOnClickListener(this); img_group_friend = (ImageView) findViewById(R.id.tab3); img_group_friend.setOnClickListener(this); myHeadImage = (ImageView) findViewById(R.id.friend_list_myImg); myName = (TextView) findViewById(R.id.friend_list_myName); cursor = (ImageView) findViewById(R.id.tab2_bg); // myHeadImage.setImageResource(imgs[list.get(0).getImg()]); myName.setText(list.get(0).getUserName()); layout_body_activity.setFocusable(true); mPager = (ViewPager) findViewById(R.id.viewPager); mListViews = new ArrayList<View>(); LayoutInflater inflater = LayoutInflater.from(this); View lay1 = inflater.inflate(R.layout.tab11, null); View lay2 = inflater.inflate(R.layout.tab22, null); View lay3 = inflater.inflate(R.layout.tab33, null); mListViews.add(lay1); mListViews.add(lay2); mListViews.add(lay3); mPager.setAdapter(new MyPagerAdapter(mListViews)); mPager.setCurrentItem(PAGE2); mPager.setOnPageChangeListener(new MyOnPageChangeListener()); // 下面是最近会话界面处理 mRecentListView = (ListView) lay1.findViewById(R.id.tab1_listView); // mRecentAdapter = new RecentChatAdapter(FriendListActivity.this, // application.getmRecentList());// 从全局变量中获取最近聊天对象数组 mRecentListView.setAdapter(application.getmRecentAdapter()); // 先设置空对象,要么从数据库中读出 // 下面是处理好友列表界面处理 // myListView = (MyListView) lay2.findViewById(R.id.tab2_listView); myExAdapter = new MyExAdapter(this, group); myListView.setAdapter(myExAdapter); myListView.setGroupIndicator(null); // 不设置大组指示器图标,因为我们自定义设置了 myListView.setDivider(null); // 设置图片可拉伸的 myListView.setFocusable(true); // 聚焦才可以下拉刷新 // 2015 myListView.setonRefreshListener(new MyRefreshListener()); // 下面是群组界面处理 mGroupListView = (ListView) lay3.findViewById(R.id.tab3_listView); List<GroupEntity> groupList = new ArrayList<GroupEntity>(); GroupEntity entity = new GroupEntity(0, "C175地带", "怀念高中生活..."); GroupEntity entity2 = new GroupEntity(0, "Android开发", "爱生活...爱Android..."); groupList.add(entity); groupList.add(entity2); GroupAdapter adapter = new GroupAdapter(this, groupList); mGroupListView.setAdapter(adapter); }
private void updateSearchList(boolean isLoadMore) { if (isLoadMore) { if (tempList != null) { searchList.addAll(tempList); searchListAdapter.notifyDataSetChanged(); if (tempList.size() < 20) { searchResultListView.setCanLoadMore(false); } searchResultListView.onLoadMoreOver(); tempList.clear(); } } else { if (tempList != null) { searchList.addAll(tempList); searchListAdapter = new SearchResultAdapter(searchList); searchResultListView.setAdapter(searchListAdapter); if (tempList.size() < 20) { searchResultListView.setCanLoadMore(false); } else { searchResultListView.setCanLoadMore(true); } if (tempList.size() == 0) { myErrText.setText("暂无结果"); myErrText.setVisibility(View.VISIBLE); } else { myErrText.setVisibility(View.GONE); } tempList.clear(); } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View more = inflater.inflate(R.layout.more, container, false); listView = (MyListView) more.findViewById(R.id.applicationlist); for (int i = 0; i < data.length; i++) { Map<String, String> map = new HashMap<String, String>(); map.put("imag", String.valueOf(imagIds[i])); map.put("text", data[i]); this.list.add(map); } adapter = new SimpleAdapter( this.getActivity(), list, R.layout.more_listadapter, new String[] {"imag", "text"}, new int[] {R.id.appimag, R.id.appdescription}); listView.setAdapter(adapter); listView.setTextFilterEnabled(true); listView.setOnRefreshListener(this); searchView = (SearchView) more.findViewById(R.id.search_view); searchView.setOnQueryTextListener(this); return more; }