示例#1
0
  /** 初始化Column栏目项 */
  private void initTabColumn() {
    mRadioGroup_content.removeAllViews();
    int count = userChannelList.size();
    mColumnHorizontalScrollView.setParam(
        this,
        mScreenWidth,
        mRadioGroup_content,
        shade_left,
        shade_right,
        ll_more_columns,
        rl_column);
    for (int i = 0; i < count; i++) {
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(mItemWidth, LayoutParams.WRAP_CONTENT);
      params.leftMargin = 5;
      params.rightMargin = 5;
      //			TextView localTextView = (TextView) mInflater.inflate(R.layout.column_radio_item, null);
      TextView columnTextView = new TextView(this);
      columnTextView.setTextAppearance(this, R.style.top_category_scroll_view_item_text);
      //
      //	localTextView.setBackground(getResources().getDrawable(R.drawable.top_category_scroll_text_view_bg));
      columnTextView.setBackgroundResource(R.drawable.radio_buttong_bg);
      columnTextView.setGravity(Gravity.CENTER);
      columnTextView.setPadding(5, 5, 5, 5);
      columnTextView.setId(i);
      columnTextView.setText(userChannelList.get(i).getName());
      columnTextView.setTextColor(
          getResources().getColorStateList(R.color.top_category_scroll_text_color_day));
      if (columnSelectIndex == i) {
        columnTextView.setSelected(true);
      }
      columnTextView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              for (int i = 0; i < mRadioGroup_content.getChildCount(); i++) {
                View localView = mRadioGroup_content.getChildAt(i);
                if (localView != v) localView.setSelected(false);
                else {
                  localView.setSelected(true);
                  mViewPager.setCurrentItem(i);
                }
              }
              Toast.makeText(
                      getApplicationContext(),
                      userChannelList.get(v.getId()).getName(),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          });
      mRadioGroup_content.addView(columnTextView, i, params);
    }
  }
示例#2
0
 /** 选择的Column里面的Tab */
 private void selectTab(int tab_postion) {
   columnSelectIndex = tab_postion;
   for (int i = 0; i < mRadioGroup_content.getChildCount(); i++) {
     View checkView = mRadioGroup_content.getChildAt(tab_postion);
     int k = checkView.getMeasuredWidth();
     int l = checkView.getLeft();
     int i2 = l + k / 2 - mScreenWidth / 2;
     // rg_nav_content.getParent()).smoothScrollTo(i2, 0);
     mColumnHorizontalScrollView.smoothScrollTo(i2, 0);
     // mColumnHorizontalScrollView.smoothScrollTo((position - 2) *
     // mItemWidth , 0);
   }
   // 判断是否选中
   for (int j = 0; j < mRadioGroup_content.getChildCount(); j++) {
     View checkView = mRadioGroup_content.getChildAt(j);
     boolean ischeck;
     if (j == tab_postion) {
       ischeck = true;
     } else {
       ischeck = false;
     }
     checkView.setSelected(ischeck);
   }
 }