public void onEvent(GetTvEvent<AppreciatetvList> event) { aList = event.result; // 处理List返回内容 if (aList == null) return; // init frequency List<Appreciatetv> list = aList.getLists(); List<CategoryData> datas = list.get(list.size() - 1).getData(); mFrequencys.clear(); for (CategoryData data : datas) { mFrequencys.add(data.getCategoryurl()); } setViewsVisiable(View.VISIBLE); mProgressBar.setVisibility(View.GONE); mListViewAdapter.updateData(aList.getLists()); Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(0); if (tv != null) { mGalleryAdapter.updateData(tv.getData()); mGallery.setSelection(Integer.MAX_VALUE / 2 - 1); } mListView.requestFocus(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(R.layout.tv_list_item, null); } Appreciatetv tv = (Appreciatetv) getItem(position); TextView text = (TextView) convertView.findViewById(R.id.tv_list_item_txt); text.setText(tv.getCategorytypename()); if (mListSelected == position) { text.setBackgroundResource(R.drawable.tv_btn_down); } else { text.setBackgroundResource(R.drawable.tv_btn_up); } return convertView; }
// TODO // int[] channels = {58437, 77937, 110500, 112937, 58437, 77937, 110500, 58437, 77937, 110500}; @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent == mListView) { // Log.d("shine", "list onItemSelected pos=" + position); Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(position); if (tv != null) { mGallery.removeAllViewsInLayout(); mGalleryAdapter.updateData(tv.getData()); mGalleySelectedPosition = Integer.MAX_VALUE / 2 - 1; mGallery.setSelection(mGalleySelectedPosition); mListSelected = position; mListViewAdapter.notifyDataSetChanged(); } } else { CategoryData data = mGalleryAdapter.getItem(position); mGalleySelectedPosition = position; mGalleryAdapter.notifyDataSetChanged(); } }