public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
  private void initTitle() {
    if (mTitleLayout == null) {
      LayoutInflater inflater = LayoutInflater.from(getContext());
      inflater.inflate(R.layout.abc_action_bar_title_item, this);
      mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
      mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
      mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
      if (mTitleStyleRes != 0) {
        mTitleView.setTextAppearance(getContext(), mTitleStyleRes);
      }
      if (mSubtitleStyleRes != 0) {
        mSubtitleView.setTextAppearance(getContext(), mSubtitleStyleRes);
      }
    }

    mTitleView.setText(mTitle);
    mSubtitleView.setText(mSubtitle);

    final boolean hasTitle = !TextUtils.isEmpty(mTitle);
    final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
    mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
    mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
    if (mTitleLayout.getParent() == null) {
      addView(mTitleLayout);
    }
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      TextView view = null;
      if (convertView == null) {
        view = new TextView(POICategoriesListActivity.this);
      } else {
        view = (TextView) convertView;
      }

      POICategoryListItem item = listItems.get(position);

      view.setText("  " + item.name);
      if (item.isMainCategory) {
        view.setTextAppearance(POICategoriesListActivity.this, R.style.menu_options_group_style);
        view.setBackgroundColor(getResources().getColor(R.color.grey_options_group));
      } else {
        view.setTextAppearance(POICategoriesListActivity.this, R.style.menu_options_style);
        if (!selectedCategories.contains(item.id)) {
          view.setBackgroundColor(getResources().getColor(R.color.white));
        } else {
          view.setBackgroundColor(getResources().getColor(R.color.selected));
        }
      }
      return view;
    }
Пример #4
0
 private void setTextAppearance(int value) {
   if (null != mHeaderText) {
     mHeaderText.setTextAppearance(getContext(), value);
   }
   if (null != mSubHeaderText) {
     mSubHeaderText.setTextAppearance(getContext(), value);
   }
 }
Пример #5
0
 @TargetApi(Build.VERSION_CODES.M)
 public static void setTextAppearance(TextView view, @StyleRes int appearanceRes) {
   if (Build.VERSION.SDK_INT < 23) {
     //noinspection deprecation
     view.setTextAppearance(view.getContext(), appearanceRes);
   } else {
     view.setTextAppearance(appearanceRes);
   }
 }
  @SuppressWarnings("deprecation")
  protected void init(Context context, AttributeSet attributes, int defStyleAttr) {
    EditText reference = new EditText(getContext());

    setOrientation(VERTICAL);
    setPadding(
        reference.getLeft() + reference.getCompoundPaddingLeft(),
        0,
        reference.getRight() + reference.getCompoundPaddingRight(),
        0);

    hint =
        (TextView)
            LayoutInflater.from(context).inflate(R.layout.floating_label_layout_hint, this, false);

    error =
        (TextView)
            LayoutInflater.from(context).inflate(R.layout.floating_label_layout_error, this, false);

    TypedArray array =
        context.obtainStyledAttributes(
            attributes,
            R.styleable.TextInputLayout,
            defStyleAttr,
            R.style.Widget_Design_TextInputLayout);

    hint.setText(array.getString(R.styleable.TextInputLayout_android_hint));

    if (array.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
      hint.setTextColor(array.getColorStateList(R.styleable.TextInputLayout_android_textColorHint));
    }

    if (array.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1) != -1) {
      setHintTextAppearance(array.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0));
    }

    final int errorAppearance =
        array.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0);

    try {
      error.setTextAppearance(getContext(), errorAppearance);
    } catch (Exception exception) {
      // Probably caused by our theme not extending from Theme.Design*. Instead
      // we manually set something appropriate
      error.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption);
      error.setTextColor(
          ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
    }

    error.setVisibility(
        array.getBoolean(R.styleable.TextInputLayout_errorEnabled, false) ? VISIBLE : GONE);

    array.recycle();
  }
Пример #7
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   TextView label = new TextView(Term.this);
   String title = getSessionTitle(position, getString(R.string.window_title, position + 1));
   label.setText(title);
   if (AndroidCompat.SDK >= 13) {
     label.setTextAppearance(Term.this, TextAppearance_Holo_Widget_ActionBar_Title);
   } else {
     label.setTextAppearance(Term.this, android.R.style.TextAppearance_Medium);
   }
   return label;
 }
  public void setFrom(final Comment comment) {
    Utils.setBackgroundDrawable(context, itemView, comment.isHighlighted());

    commentAuthor.setText(comment.getAuthor());
    commentAuthor.setTextAppearance(
        context,
        comment.isHighlighted()
            ? R.style.SmallText
            : comment.isOp() ? R.style.SmallText_HighlightOp : R.style.SmallText_NormalUser);
    Utils.setBackgroundDrawable(
        context,
        commentAuthor,
        comment.isOp() && !comment.isHighlighted(),
        R.attr.colorAccountHeader);

    commentTime.setText(comment.getTimeAgo());
    commentTime.setTextAppearance(
        context, comment.isHighlighted() ? R.style.SmallText : R.style.SmallText_Light);

    commentContent.setText(Utils.fromHtml(context, comment.getContent(), !comment.isDeleted()));

    // Space before the marker
    ViewGroup.LayoutParams params = commentIndent.getLayoutParams();
    params.width =
        commentMarker.getLayoutParams().width * Math.min(MAX_VISIBLE_DEPTH, comment.getDepth());
    commentIndent.setLayoutParams(params);

    Picasso.with(context)
        .load(comment.getAvatar())
        .placeholder(R.drawable.default_avatar_mask)
        .transform(new RoundedCornersTransformation(20, 0))
        .into(commentImage);
    View.OnClickListener viewProfileListener =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            fragment.showProfile(comment.getAuthor());
          }
        };
    commentImage.setOnClickListener(viewProfileListener);
    commentAuthor.setOnClickListener(viewProfileListener);

    writeCommentListener =
        comment.getId() == 0
            ? null
            : new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                fragment.requestComment(comment);
              }
            };
  }
  @Override
  protected View onCreateView(ViewGroup parent) {

    LinearLayout layout = new LinearLayout(getContext());
    LinearLayout.LayoutParams params1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    // params1.gravity = Gravity.LEFT;
    params1.weight = 1.0f;
    layout.setPadding(15, 10, 10, 10);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    TextView view = new TextView(getContext());
    view.setText(R.string.rerun_setup_wizard);
    // view.setTextSize(18);
    // view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    view.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
    // view.setGravity(Gravity.LEFT);
    view.setLayoutParams(params1);

    this.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference arg0) {
            getContext().startActivity(new Intent(getContext(), WizardActivity.class));
            return true;
          }
        });

    layout.addView(view);
    layout.setId(android.R.id.widget_frame);
    return layout;
  }
Пример #10
0
  /**
   * onCreate之后调用,可以用来初始化view
   *
   * @param savedInstanceState the saved instance state
   */
  @Override
  public final void onCreateAfter(Bundle savedInstanceState) {
    parseIntent();

    enableJavascript();
    enableCaching();
    enableClient();
    enableAdjust();
    zoomedOut();
    // 网页标题
    mTextSwitcher.setFactory(
        () -> {
          TextView textView = new TextView(this);
          textView.setTextAppearance(this, R.style.WebTitle);
          textView.setSingleLine(true);
          textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
          textView.postDelayed(() -> textView.setSelected(true), 1738);
          return textView;
        });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (title != null) setTitle(title);

    if (mProgressBar != null)
      mProgressBar.setReachedBarColor(BaseApplication.color(R.color.colorPrimary));

    // 设置滑动监听
    mWebView.setOnScrollChangedCallback(
        (dx, dy, x, y) -> { // 滑动监听
        });

    onCreateAfterLater();
  }
Пример #11
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      IconContextMenuItem item = (IconContextMenuItem) getItem(position);

      Resources res = parentActivity.getResources();

      if (convertView == null) {
        TextView temp = new TextView(context);
        AbsListView.LayoutParams param =
            new AbsListView.LayoutParams(
                AbsListView.LayoutParams.FILL_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
        temp.setLayoutParams(param);
        temp.setPadding((int) toPixel(res, 15), 0, (int) toPixel(res, 15), 0);
        temp.setGravity(android.view.Gravity.CENTER_VERTICAL);

        Theme th = context.getTheme();
        TypedValue tv = new TypedValue();

        if (th.resolveAttribute(android.R.attr.textAppearanceLargeInverse, tv, true)) {
          temp.setTextAppearance(context, tv.resourceId);
        }

        temp.setMinHeight(LIST_PREFERED_HEIGHT);
        temp.setCompoundDrawablePadding((int) toPixel(res, 14));
        convertView = temp;
      }

      TextView textView = (TextView) convertView;
      textView.setTag(item);
      textView.setText(item.text);
      textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);

      return textView;
    }
Пример #12
0
  private TextView initializeTextView(final Resources resources) {
    TextView text = new TextView(this.activity);
    text.setId(TEXT_ID);
    text.setText(this.text);
    //        text.setTypeface(Typeface.DEFAULT_BOLD);
    text.setGravity(this.style.gravity);

    // set the text color if set
    if (this.style.textColorValue != Style.NOT_SET) {
      text.setTextColor(this.style.textColorValue);
    } else if (this.style.textColorResourceId != 0) {
      text.setTextColor(resources.getColor(this.style.textColorResourceId));
    }

    // Set the text size. If the user has set a text size and text
    // appearance, the text size in the text appearance
    // will override this.
    if (this.style.textSize != 0) {
      text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize);
    }

    // Setup the shadow if requested
    if (this.style.textShadowColorResId != 0) {
      initializeTextViewShadow(resources, text);
    }

    // Set the text appearance
    if (this.style.textAppearanceResId != 0) {
      text.setTextAppearance(this.activity, this.style.textAppearanceResId);
    }
    return text;
  }
 private void init(AttributeSet attrs) {
   int weekTextStyle;
   TypedArray typedArray = null;
   // 获取所有的资源文件
   if (attrs != null) {
     typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.TtCalendar);
     // 星期是card
     weekTextStyle =
         typedArray.getResourceId(
             R.styleable.TtCalendar_weekTextStyle, R.style.textView_sp13_grey_bg_bold);
   } else {
     weekTextStyle = R.style.textView_sp13_grey_bg_bold;
   }
   inflate(mContext, R.layout.widget_calendar_pageview, this);
   setGravity(Gravity.CENTER_HORIZONTAL);
   setOrientation(LinearLayout.VERTICAL);
   LinearLayout weekdaysLl = (LinearLayout) this.findViewById(R.id.widget_calendar_card_weekdays);
   // 设置星期文字样式
   for (int i = 0; i < weekdaysLl.getChildCount(); i++) {
     View child = weekdaysLl.getChildAt(i);
     if (child instanceof TextView) {
       ((TextView) child).setTextAppearance(mContext, weekTextStyle);
     }
   }
   mCalendarCardView = (CalendarCardView) this.findViewById(R.id.widget_calendar_pageview_card);
   mCalendarCardView.setTypedArray(typedArray);
 }
Пример #14
0
    @Override
    protected void onPreExecute() {
      super.onPreExecute();

      LinearLayout linearLayout = new LinearLayout(MainActivity.this);
      ViewGroup.LayoutParams layoutParams =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      linearLayout.setLayoutParams(layoutParams);
      linearLayout.setOrientation(LinearLayout.HORIZONTAL);
      linearLayout.setGravity(Gravity.CENTER);

      ProgressBar progressBar = new ProgressBar(MainActivity.this);
      progressBar.setLayoutParams(layoutParams);

      TextView textView = new TextView(MainActivity.this);
      textView.setLayoutParams(layoutParams);
      textView.setText("Deleting...");
      textView.setTextAppearance(MainActivity.this, android.R.style.TextAppearance_Large);

      TextView textViewspace = new TextView(MainActivity.this);
      textView.setLayoutParams(layoutParams);
      textView.setText("  ");

      linearLayout.addView(progressBar);
      // linearLayout.addView(textViewspace);
      linearLayout.addView(textView);

      AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
      builder.setTitle("Deleting Questions").setView(linearLayout).setCancelable(true);

      alertDialog = builder.create();
      alertDialog.show();
    }
Пример #15
0
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    // Create a text view supposed to display tuto messages
    if (mTutoTextView == null) {
      mTutoTextView = new TextView(getContext());
      mTutoTextView.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
      mTutoTextView.setTextColor(getResources().getColor(R.color.white));
      mTutoTextView.setTypeface(null, Typeface.BOLD);
      mTutoTextView.setBackgroundResource(R.color.alpha_shadow);
      mTutoTextView.setGravity(Gravity.CENTER);
      final int padding = getResources().getDimensionPixelSize(R.dimen.default_padding);
      mTutoTextView.setPadding(padding, 2 * padding, padding, padding);

      final RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      mTutoTextView.setLayoutParams(layoutParams);
    }

    mAnimationLayer.addView(mTutoTextView);
    displayCurrentStepMessage(false);
  }
    private View createViewFromResource(
        int position, View convertView, ViewGroup parent, int resource) {
      TextView textView;

      if (convertView == null) {
        textView = (TextView) mInflater.inflate(resource, parent, false);
        textView.setAllCaps(true);
        textView.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
        textView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
        textView.setTextColor(mTextColor);
        textView.setEllipsize(TruncateAt.MIDDLE);
      } else {
        textView = (TextView) convertView;
      }

      EditType type = getItem(position);
      String text;
      if (type == CUSTOM_SELECTION) {
        text = mEntry.getAsString(mType.customColumn);
      } else {
        text = getContext().getString(type.labelRes);
      }
      textView.setText(text);
      return textView;
    }
Пример #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ButterKnife.bind(this);
    mContext = this;
    mUrl = getIntent().getStringExtra(EXTRA_URL);
    mTitle = getIntent().getStringExtra(EXTRA_TITLE);

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    mWebView.setWebChromeClient(new ChromeClient());
    mWebView.setWebViewClient(new LoveClient());

    mWebView.loadUrl(mUrl);

    mTextSwitcher.setFactory(
        () -> {
          TextView textView = new TextView(this);
          textView.setTextAppearance(this, R.style.WebTitle);
          textView.setSingleLine(true);
          textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
          textView.postDelayed(() -> textView.setSelected(true), 1738);
          return textView;
        });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (mTitle != null) setTitle(mTitle);
  }
Пример #18
0
  public VerticalCardView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.com_gabm_fancyplaces_VerticalCardView, 0, 0);

    try {
      title = a.getString(R.styleable.com_gabm_fancyplaces_VerticalCardView_card_title);
    } finally {
      a.recycle();
    }

    // own settings
    this.setOrientation(VERTICAL);
    this.setPadding(30, 30, 30, 30);

    // text view as title
    TextView textView = new TextView(context);
    textView.setText(title);
    textView.setTextAppearance(context, R.style.TextAppearance_AppCompat_Large);
    textView.setTypeface(null, Typeface.BOLD);
    textView.setPadding(0, 20, 0, 10);
    this.addView(textView);
  }
Пример #19
0
  public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    final int sidePadding =
        a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelSidePadding,
            dipsToPix(DEFAULT_PADDING_LEFT_RIGHT_DP));
    mLabel = new TextView(context);
    mLabel.setPadding(sidePadding, 0, sidePadding, 0);
    mLabel.setVisibility(INVISIBLE);

    mLabel.setTextAppearance(
        context,
        a.getResourceId(
            R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));

    int triggerInt =
        a.getInt(R.styleable.FloatLabelLayout_floatLabelTrigger, Trigger.TYPE.getValue());
    mTrigger = Trigger.fromValue(triggerInt);

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    a.recycle();
  }
    /**
     * Constructor
     *
     * @param parent the container view of this one
     * @param tabId drawable for the tab
     * @param barId drawable for the bar
     * @param targetId drawable for the target
     */
    Slider(ViewGroup parent, int tabId, int barId, int targetId) {
      // Create tab
      tab = new ImageView(parent.getContext());
      tab.setBackgroundResource(tabId);
      tab.setScaleType(ScaleType.CENTER);
      tab.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

      // Create hint TextView
      text = new TextView(parent.getContext());
      text.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
      text.setBackgroundResource(barId);
      text.setTextAppearance(parent.getContext(), R.style.TextAppearance_SlidingTabNormal);
      // hint.setSingleLine();  // Hmm.. this causes the text to disappear off-screen

      // Create target
      target = new ImageView(parent.getContext());
      target.setImageResource(targetId);
      target.setScaleType(ScaleType.CENTER);
      target.setLayoutParams(
          new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      target.setVisibility(View.INVISIBLE);

      parent.addView(target); // this needs to be first - relies on painter's algorithm
      parent.addView(tab);
      parent.addView(text);
    }
  /** 初始化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);
      }
    }
  }
Пример #22
0
 public View getView(int i, View view, ViewGroup viewgroup) {
   view = ((LayoutInflater) mContext.getSystemService("layout_inflater")).inflate(0x1090003, null);
   view.setBackgroundColor(mContext.getResources().getColor(0x7f070016));
   ((TextView) view).setText((String) getItem(i));
   ((TextView) view).setTextAppearance(mContext, 0x1030044);
   ((TextView) view).setTypeface(Application.getInstance().getTypeFace());
   return view;
 }
 void setState(int state) {
   text.setPressed(state == STATE_PRESSED);
   tab.setPressed(state == STATE_PRESSED);
   if (state == STATE_ACTIVE) {
     final int[] activeState = new int[] {com.android.internal.R.attr.state_active};
     if (text.getBackground().isStateful()) {
       text.getBackground().setState(activeState);
     }
     if (tab.getBackground().isStateful()) {
       tab.getBackground().setState(activeState);
     }
     text.setTextAppearance(text.getContext(), R.style.TextAppearance_SlidingTabActive);
   } else {
     text.setTextAppearance(text.getContext(), R.style.TextAppearance_SlidingTabNormal);
   }
   currentState = state;
 }
Пример #24
0
  public PagerTitleStrip(Context context, AttributeSet attrs) {
    super(context, attrs);

    addView(mPrevText = new TextView(context));
    addView(mCurrText = new TextView(context));
    addView(mNextText = new TextView(context));

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    final int textAppearance = a.getResourceId(0, 0);
    if (textAppearance != 0) {
      mPrevText.setTextAppearance(context, textAppearance);
      mCurrText.setTextAppearance(context, textAppearance);
      mNextText.setTextAppearance(context, textAppearance);
    }
    if (a.hasValue(1)) {
      final int textColor = a.getColor(1, 0);
      mPrevText.setTextColor(textColor);
      mCurrText.setTextColor(textColor);
      mNextText.setTextColor(textColor);
    }
    final int textSize = a.getDimensionPixelSize(2, 0);
    if (textSize != 0) {
      mPrevText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
      mCurrText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
      mNextText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    }
    a.recycle();

    final int defaultColor = mPrevText.getTextColors().getDefaultColor();
    final int transparentColor = (SIDE_ALPHA << 24) | (defaultColor & 0xFFFFFF);
    mPrevText.setTextColor(transparentColor);
    mNextText.setTextColor(transparentColor);

    mPrevText.setEllipsize(TruncateAt.END);
    mCurrText.setEllipsize(TruncateAt.END);
    mNextText.setEllipsize(TruncateAt.END);
    mPrevText.setSingleLine();
    mCurrText.setSingleLine();
    mNextText.setSingleLine();

    final float density = context.getResources().getDisplayMetrics().density;
    mScaledTextSpacing = (int) (TEXT_SPACING * density);
  }
Пример #25
0
  private void updateUiFromCurrentStatus() {
    // if we have no status, do nothing
    if (statuses == null) return;

    // dynamically create the UI from the status objects
    LinearLayout container = (LinearLayout) findViewById(R.id.statuses);
    container.removeAllViews();
    for (int i = 0; i < statuses.size(); i++) {
      // here, we dynamically create the various text elements and add them to our container
      com.districttaco.android.Status status = statuses.get(i);
      TextView locationName = new TextView(this);
      locationName.setText(status.getLocationName());
      locationName.setTextAppearance(this, R.style.StatusHeader);
      container.addView(locationName);
      TextView locationDescription = new TextView(this);
      locationDescription.setText(status.getLocationDescription());
      locationDescription.setTextAppearance(this, R.style.StatusContent);
      locationDescription.setPadding(12, 0, 0, 0);
      container.addView(locationDescription);
      TextView special = new TextView(this);
      special.setText(R.string.special);
      special.setTextAppearance(this, R.style.StatusHeader);
      container.addView(special);
      TextView statusDetail = new TextView(this);
      statusDetail.setText(status.getStatusText());
      statusDetail.setTextAppearance(this, R.style.StatusContent);
      statusDetail.setPadding(12, 0, 0, 0);
      container.addView(statusDetail);
      TextView infoHeader = new TextView(this);
      infoHeader.setText(status.getInfoHeader());
      infoHeader.setTextAppearance(this, R.style.InfoHeader);
      infoHeader.setPadding(0, 16, 0, 0);
      container.addView(infoHeader);
      TextView infoTitle = new TextView(this);
      infoTitle.setText(status.getInfoTitle());
      infoTitle.setTextAppearance(this, R.style.StatusHeader);
      container.addView(infoTitle);
      TextView infoBody = new TextView(this);
      infoBody.setText(status.getInfoBody());
      infoBody.setTextAppearance(this, R.style.StatusContent);
      infoBody.setPadding(12, 0, 0, 0);
      container.addView(infoBody);
    }

    // update last fetch time
    if (lastFetch != null) {
      TextView lastUpdate = new TextView(this);
      SimpleDateFormat formatter = new SimpleDateFormat(getString(R.string.date_format));
      lastUpdate.setText(formatter.format(lastFetch));
      lastUpdate.setTextAppearance(this, R.style.Footer);
      container.addView(lastUpdate);
    }
  }
Пример #26
0
 public void setEmptyText(CharSequence text) {
   ensureContent();
   if (mEmptyView != null && mEmptyView instanceof TextView) {
     TextView emptyView = (TextView) mEmptyView;
     emptyView.setText(text);
     // align text size with support library's empty text
     emptyView.setTextAppearance(this, android.R.style.TextAppearance_Small);
   } else {
     throw new IllegalStateException("Can't be used with a custom content view");
   }
 }
 private TextView makeCrumbView(String name) {
   TextView tv = new TextView(mContext);
   tv.setTextAppearance(mContext, android.R.style.TextAppearance_Medium);
   tv.setPadding(mCrumbPadding, 0, mCrumbPadding, 0);
   tv.setGravity(Gravity.CENTER_VERTICAL);
   tv.setText(name);
   tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
   tv.setSingleLine();
   tv.setEllipsize(TextUtils.TruncateAt.END);
   return tv;
 }
Пример #28
0
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    ImogBeanCursor<?> c = (ImogBeanCursor<?>) cursor;

    view.findViewById(android.R.id.background).setBackgroundDrawable(mColor);

    TextView main = (TextView) view.findViewById(android.R.id.text1);
    TextView secondary = (TextView) view.findViewById(android.R.id.text2);

    main.setText(null);
    secondary.setText(null);

    if (c.getFlagRead()) {
      view.setBackgroundResource(android.R.drawable.list_selector_background);
      main.setTextAppearance(context, android.R.style.TextAppearance_Medium);
      main.setTypeface(Typeface.DEFAULT);
      secondary.setTextAppearance(context, android.R.style.TextAppearance_Small);
      secondary.setTypeface(Typeface.DEFAULT);
    } else {
      view.setBackgroundResource(R.drawable.imog__list_selector_background_inverse);
      main.setTextAppearance(context, android.R.style.TextAppearance_Medium_Inverse);
      main.setTypeface(Typeface.DEFAULT_BOLD);
      secondary.setTextAppearance(context, android.R.style.TextAppearance_Small_Inverse);
      secondary.setTypeface(Typeface.DEFAULT_BOLD);
    }

    ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
    if (icon != null) {
      icon.setImageResource(android.R.drawable.stat_notify_sync);
      icon.setVisibility(c.getFlagSynchronized() ? View.GONE : View.VISIBLE);
    }

    main.setText(c.getMainDisplay(context));
    String sec = c.getSecondaryDisplay(context);
    if (TextUtils.isEmpty(sec.trim())) {
      secondary.setVisibility(View.GONE);
    } else {
      secondary.setVisibility(View.VISIBLE);
      secondary.setText(sec);
    }
  }
Пример #29
0
 private View createSimpleListItem18(Context ctx) {
   TextView view = new TextView(ctx);
   view.setId(android.R.id.text1);
   view.setLayoutParams(
       new AbsListView.LayoutParams(
           AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
   view.setTextAppearance(ctx, android.R.attr.textAppearanceMedium);
   int padding = BDUtils.dip2px(ctx, 16);
   view.setPadding(padding, padding, padding, padding);
   view.setGravity(Gravity.CENTER);
   return view;
 }
Пример #30
0
  private void applyTextStyle(TextView tv, int styleId) {

    tv.setTextAppearance(getContext(), styleId);

    TypedArray a =
        getContext()
            .getTheme()
            .obtainStyledAttributes(styleId, R.styleable.CustTextView); // new int[] {R.attr.font}
    String font = a.getString(R.styleable.CustTextView_font);
    if (font != null) FontManager.setFont(tv, font);
    a.recycle();
  }