List of usage examples for android.widget TextView setSingleLine
public void setSingleLine()
From source file:com.nttec.everychan.ui.NewTabFragment.java
private void openLocal() { if (!CompatibilityUtils.hasAccessStorage(activity)) return;//from w w w . j av a 2s. c o m final ListAdapter savedThreadsAdapter = new ArrayAdapter<Object>(activity, 0) { private static final int HEAD_ITEM = 0; private static final int NORMAL_ITEM = 1; private LayoutInflater inflater = LayoutInflater.from(activity); private int drawablePadding = (int) (resources.getDisplayMetrics().density * 5 + 0.5f); { add(new Object()); for (Database.SavedThreadEntry entity : MainApplication.getInstance().database.getSavedThreads()) { File file = new File(entity.filepath); if (file.exists()) add(entity); } } @Override public View getView(int position, View convertView, ViewGroup parent) { View v; if (position == 0) { v = convertView == null ? inflater.inflate(android.R.layout.simple_list_item_1, parent, false) : convertView; TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setText(R.string.newtab_select_local_file); } else { Database.SavedThreadEntry item = (Database.SavedThreadEntry) getItem(position); v = convertView == null ? inflater.inflate(android.R.layout.simple_list_item_2, parent, false) : convertView; TextView t1 = (TextView) v.findViewById(android.R.id.text1); TextView t2 = (TextView) v.findViewById(android.R.id.text2); t1.setSingleLine(); t2.setSingleLine(); t1.setEllipsize(TextUtils.TruncateAt.END); t2.setEllipsize(TextUtils.TruncateAt.START); t1.setText(item.title); t2.setText(item.filepath); ChanModule chan = MainApplication.getInstance().getChanModule(item.chan); if (chan != null) { t1.setCompoundDrawablesWithIntrinsicBounds(chan.getChanFavicon(), null, null, null); t1.setCompoundDrawablePadding(drawablePadding); } } return v; } @Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { return position == 0 ? HEAD_ITEM : NORMAL_ITEM; } }; if (savedThreadsAdapter.getCount() == 1) { selectFile(); return; } DialogInterface.OnClickListener listListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { selectFile(); } else { Database.SavedThreadEntry item = (Database.SavedThreadEntry) savedThreadsAdapter.getItem(which); LocalHandler.open(item.filepath, activity); } } }; new AlertDialog.Builder(activity).setTitle(R.string.newtab_saved_threads_title) .setAdapter(savedThreadsAdapter, listListener).setNegativeButton(android.R.string.cancel, null) .show(); }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
private void addRedDotTab(final int position, String title, int resId) { LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.HORIZONTAL); tabLayout.setGravity(Gravity.CENTER); TextView tab = new TextView(getContext()); tab.setText(title);//from ww w. j a v a 2 s. co m tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(getResources().getColorStateList(R.color.pst_tab_text_selector)); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (null != mOnPageClickedLisener) { mOnPageClickedLisener.onPageClicked(position); } pager.setCurrentItem(position); } }); tabLayout.addView(tab, 0); ImageView tabImg = new ImageView(getContext()); LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tabImgParams.setMargins(DeviceUtils.dip2px(getContext(), 5), DeviceUtils.dip2px(getContext(), 10), 0, 0); tabImgParams.gravity = Gravity.TOP; tabImg.setLayoutParams(tabImgParams); tabLayout.addView(tabImg, 1); tabsContainer.addView(tabLayout); }
From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w. j a va 2 s . com tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTypeface(App.skrift_gibson); addTab(position, tab); }
From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java
private void addWarningTab(final int position, String title, int resId) { LinearLayout tabLayout = new LinearLayout(getContext()); tabLayout.setOrientation(LinearLayout.HORIZONTAL); tabLayout.setGravity(Gravity.CENTER); ImageView tabImg = new ImageView(getContext()); int width = DimenUtils.dp2px(getContext(), 18); LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(width, width); tabImgParams.setMargins(0, 0, DimenUtils.dp2px(getContext(), 10), 0); tabImgParams.gravity = Gravity.CENTER; tabImg.setLayoutParams(tabImgParams); if (resId != -1) { tabImg.setBackgroundResource(resId); tabImg.setVisibility(View.VISIBLE); } else {/*w ww. j a v a 2 s . co m*/ tabImg.setVisibility(View.GONE); } tabLayout.addView(tabImg, 0); TextView tab = new TextView(getContext()); tab.setText(title); tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(getResources().getColorStateList( mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector)); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f); tabLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (null != mOnPageClickedLisener) { mOnPageClickedLisener.onPageClicked(position); } pager.setCurrentItem(position); } }); tabLayout.addView(tab, 1); tabsContainer.addView(tabLayout); }
From source file:com.research.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { LinearLayout item = new LinearLayout(getContext()); item.setOrientation(LinearLayout.HORIZONTAL); item.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); TextView tab = new TextView(getContext()); tab.setText(title);/*from ww w . j a va 2 s.co m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); TextView msgTipText = new TextView(getContext()); msgTipText.setGravity(Gravity.CENTER); msgTipText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); msgTipText.setSingleLine(); msgTipText.setTextColor(Color.parseColor("#ffffff")); if (position != 0) { msgTipText.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.main_find_icon)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( FeatureFunction.dip2px(BMapApiApp.getInstance(), 10), FeatureFunction.dip2px(BMapApiApp.getInstance(), 10)); msgTipText.setLayoutParams(params); } else { msgTipText.setBackgroundDrawable(getContext().getResources().getDrawable(R.drawable.message_count_bg)); } msgTipText.setVisibility(View.GONE); item.addView(tab); item.addView(msgTipText); addTab(position, item); }
From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java
private void addTextWithIconTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* w w w . ja v a 2s . com*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setPadding(tabMargin, 0, tabMargin, 0); tab.setTextColor(tabTextColor); // tab.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.btn_tab_mendian_selector, 0, 0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java
/** add one text tab */ private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w .j ava 2 s .c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.guerinet.materialtabs.TabLayout.java
/** * Sets up the title {@link TextView} as per the material guidelines * * @param textView The TextView//www . j a va2 s. c om */ private void prepareTextView(TextView textView) { //Keep it to 1 line or the selectors won't work textView.setSingleLine(); //Set the text to all caps if we are in 14+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } //Tabs are bold textView.setTypeface(Typeface.DEFAULT_BOLD); }
From source file:com.insthub.ecmobile.component.PagerSlidingTabStrip.java
/** add one text tab */ private void addTextTab(final int position, String title, int res) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w ww . ja va 2s . c om*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); Drawable drawable = getResources().getDrawable(res); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tab.setCompoundDrawables(drawable, null, null, null); addTab(position, tab); }
From source file:com.example.linkagescroll.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setTextSize(14);/*from w w w .j ava 2 s . c o m*/ tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }