Example usage for android.widget TextView setSingleLine

List of usage examples for android.widget TextView setSingleLine

Introduction

In this page you can find the example usage for android.widget TextView setSingleLine.

Prototype

public void setSingleLine() 

Source Link

Document

Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.

Usage

From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java

private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) {
      FrameLayout tabfl = new FrameLayout(getContext());
      ImageView tabi = new ImageView(getContext());
      tabi.setContentDescription(title);
      tabi.setImageResource(resId);/*  w w  w.  j a va2 s .  c o  m*/
      tabi.setVisibility(View.INVISIBLE);
      TextView tabt = new TextView(getContext());
      tabt.setText(title);
      tabt.setTypeface(App.skrift_gibson);
      tabt.setGravity(Gravity.CENTER);
      tabt.setSingleLine();

      tabfl.addView(tabi);
      tabfl.addView(tabt);

      LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
      lp.gravity = Gravity.CENTER;
      lp = (LayoutParams) tabt.getLayoutParams();
      lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
      lp.gravity = Gravity.CENTER;

      addTab(position, tabfl);
  }

From source file:com.android.yijiang.kzx.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext(), null, android.R.attr.textAppearanceMedium);
    tab.setText(title);//from ww  w . j  a va 2  s  .  co m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:com.mingle.discolor.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title, int width) {

    TextView tab = new TextView(getContext());

    tab.setText(title);//from   w  w w.j  av  a  2 s.c  o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    android.view.ViewGroup.LayoutParams params = tab.getLayoutParams();
    if (params == null) {
        params = new LayoutParams(width, LayoutParams.FILL_PARENT);
    }

    addTab(position, tab, params);
}

From source file:com.hongbaogou.view.PagerSlidingTabStrip.java

public void addTextTab(final int position, String title) {

    //      TextView tab = new TextView(getContext());
    TextView tab = (TextView) View.inflate(getContext(), R.layout.list_item, null);
    //      tab.setTextSize(Dip2PxUtils.sp2px(getContext(),25));
    //      tab.setTextSize(50);
    tab.setText(title);//from   w w w .  j ava2  s. c o  m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    addTab(position, tab);
}

From source file:cn.com.incito.driver.UI.detailDialog.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);/*  w w  w  .  jav  a  2  s . c o m*/
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:scroll.com.rdemo.scroll.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);//from w  w w.j  a v a  2 s. c  o  m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextSize(tabTextSize);
    if (tabTextWidth > 0) {
        int tabWidth = tabTextWidth;
        if (tabTextAugmenter > 0 && title.length() > 3) {
            tabWidth += tabTextAugmenter * (title.length() - 2);
        }
        tab.setWidth(tabWidth);
    }
    addTab(position, tab);
}

From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java

/** add one number indicator tab */
private void addNumTab(final int position, String title, int num) {
    LinearLayout tab = new LinearLayout(getContext());
    TextView titleText = new TextView(getContext());
    TextView numText = new TextView(getContext());

    titleText.setText(title);/*from  ww w.  ja  v a  2s .co  m*/
    titleText.setGravity(Gravity.CENTER);
    titleText.setSingleLine();

    numText.setText(Integer.toString(num));
    numText.setGravity(Gravity.CENTER);
    numText.setPadding(mNumPadding, 1, mNumPadding, 1);
    numText.setSingleLine();

    /* if the number is 0, set invisible */
    if (num == 0) {
        numText.setVisibility(View.GONE);
    } else {
        numText.setVisibility(View.VISIBLE);
    }

    tab.addView(titleText, 0, mDefaultTabLayoutParams);
    tab.addView(numText, 1, mNumLayoutParams);
    tab.setGravity(Gravity.CENTER);

    addTab(position, tab);
}

From source file:com.hcpt.fastfood.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position) {

    TextView tab = new TextView(getContext());
    if (!arrTabs.isEmpty()) {
        // Set text
        tab.setText(arrTabs.get(position).getTitle());
        tab.setTypeface(null, Typeface.BOLD);
        tab.setGravity(Gravity.CENTER_HORIZONTAL);
        tab.setSingleLine();

        // Set icon

        Drawable iconDrawable = getResources().getDrawable(arrTabs.get(position).getIcon());
        tab.setCompoundDrawablesWithIntrinsicBounds(null, iconDrawable, null, null);
    }//from   w  w w .jav  a 2s . c o m

    addTab(position, tab);
}

From source file:com.csdn.pagerslidingtabstrip.view.PagerSlidingTabStrip.java

private void addTextTab2(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from   w w w  . j  ava2  s. co  m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    addTab2(position, tab);
}

From source file:com.tpos.widget.pagertab.PagerSlidingTabStrip.java

private void addIconTextTab(final int position, int resId, String title) {

    TextView tab = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.item_tabstrip_view, null);
    // new TextView(getContext());
    tab.setText(title);// w  ww .j a va  2  s  .  c  o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    Drawable tDrawable = null;
    try {
        tDrawable = getResources().getDrawable(resId);
    } catch (NotFoundException e) {
        e.printStackTrace();
        tDrawable = null;
    }
    if (tDrawable != null) {
        tDrawable.setBounds(0, 0, (int) (tDrawable.getIntrinsicWidth() * 0.5),
                (int) (tDrawable.getIntrinsicHeight() * 0.5));
        tab.setCompoundDrawables(null, tDrawable, null, null);
    }

    addTab(position, tab);

}