Exemplo n.º 1
0
 private void setTextAppearance(int value) {
   if (null != mHeaderText) {
     mHeaderText.setTextAppearance(getContext(), value);
   }
   if (null != mSubHeaderText) {
     mSubHeaderText.setTextAppearance(getContext(), value);
   }
 }
  /** 初始化Column栏目项 */
  private void initTabColumn() {
    mRadioGroup_content.removeAllViews();

    if (mUserChannelList != null) {
      int count = mUserChannelList.size();
      mColumnHorizontalScrollView.setParam(
          getActivity(),
          mScreenWidth,
          mRadioGroup_content,
          mShadeleft,
          mShaderight,
          ll_more_columns,
          rl_column);
      for (int i = 0; i < count; i++) {
        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        params.rightMargin = 5;
        //			TextView localTextView = (TextView) mInflater.inflate(R.layout.column_radio_item,
        // null);
        TextView columnTextView = new TextView(getActivity());
        columnTextView.setTextAppearance(getActivity(), 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(mUserChannelList.get(i).getName());
        columnTextView.setTextColor(
            getResources().getColorStateList(R.color.top_category_scroll_text_color_day));
        if (columnSelectIndex == i) {
          columnTextView.setSelected(true);
        }
        columnTextView.setOnClickListener(
            new View.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(
                        getActivity().getApplicationContext(),
                        mUserChannelList.get(v.getId()).getName(),
                        Toast.LENGTH_SHORT)
                    .show();
              }
            });
        mRadioGroup_content.addView(columnTextView, i, params);
      }
    }
  }
  /**
   * Parse a html tag <a href="www.example.com">example</a> and linkifies to 'example' then put that
   * text in a text view and appends it to the ulr viewgroup.
   *
   * @param urls: urls to linkify.
   */
  private void fillUrlsLayout(Url[] urls) {

    if (getActivity() != null) {
      for (Url link : urls) {
        String url = "<a href=\"" + link.getValue() + "\"> - " + link.getLabel() + "</a>\n";

        TextView urlTextView = new TextView(getActivity());
        urlTextView.setText(Html.fromHtml(url));
        urlTextView.setMovementMethod(LinkMovementMethod.getInstance());
        urlTextView.setTextAppearance(getActivity(), R.style.LinkStyle);

        groupURLLayout.addView(urlTextView, GuiUtils.getLinkParams());

        Url urlEnt = new Url();
        urlEnt.setGroup_id(Configuration.GROUP_ID);
        urlEnt.setLabel(link.getLabel());
        urlEnt.setValue(link.getValue());

        dbHandler.insertElement(Url.class, urlEnt.getFields());
      }
    }
  }
Exemplo n.º 4
0
 /**
  * Sets the text color, size, style from the specified TextAppearance resource.
  *
  * @param resId The resourceId value.
  * @return This SnackBar for chaining methods.
  */
 public SnackBar textAppearance(int resId) {
   if (resId != 0) mText.setTextAppearance(getContext(), resId);
   return this;
 }