List of usage examples for android.widget TextView setEllipsize
public void setEllipsize(TextUtils.TruncateAt where)
From source file:org.gnucash.android.util.CommoditiesCursorAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setEllipsize(TextUtils.TruncateAt.MIDDLE); String currencyName = cursor/*from w ww . ja v a 2s. co m*/ .getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_FULLNAME)); String currencyCode = cursor .getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_MNEMONIC)); textView.setText(currencyCode + " - " + currencyName); }
From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java
public void setToolbar(Toolbar toolbar) { setSupportActionBar(toolbar);/*from w w w.j a va 2 s . co m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); try { if (toolbar.getClass() != null) { Field f = toolbar.getClass().getDeclaredField("mTitleTextView"); f.setAccessible(true); TextView titleTextView = (TextView) f.get(toolbar); titleTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); titleTextView.setFocusable(true); titleTextView.setFocusableInTouchMode(true); titleTextView.requestFocus(); titleTextView.setSingleLine(true); titleTextView.setSelected(true); titleTextView.setMarqueeRepeatLimit(-1); } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.creationgroundmedia.popularmovies.reviews.ReviewFragment.java
@Override public void onLoadFinished(Loader<List<ReviewItem>> loader, final List<ReviewItem> data) { if (data != null) { for (ReviewItem review : data) { View tv = LayoutInflater.from(getContext()).inflate(R.layout.fragment_review, null); ((LinearLayout) mView).addView(tv); TextView authorView = (TextView) tv.findViewById(R.id.author); authorView.setText(String.format("Review by %s", review.getAuthor())); final TextView contentView = (TextView) tv.findViewById(R.id.content); contentView.setMaxLines(PREVIEW_LINES); contentView.setEllipsize(TextUtils.TruncateAt.END); contentView.setSelected(false); contentView.setText(review.getContent()); tv.setOnClickListener(new View.OnClickListener() { @Override//from ww w.jav a2s . c om public void onClick(View v) { if (contentView.isSelected()) { contentView.setEllipsize(TextUtils.TruncateAt.END); contentView.setMaxLines(PREVIEW_LINES); contentView.setSelected(false); } else { contentView.setEllipsize(null); contentView.setMaxLines(Integer.MAX_VALUE); contentView.setSelected(true); } } }); } getLoaderManager().destroyLoader(URL_REVIEWLOADER); } }
From source file:com.amazon.android.tv.tenfoot.presenter.CardPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Context context = parent.getContext(); try {//from w ww . ja v a 2 s. c o m mDefaultCardImage = ContextCompat.getDrawable(context, R.drawable.movie); sFocusedFadeMask = ContextCompat.getDrawable(context, R.drawable.content_fade_focused); } catch (Resources.NotFoundException e) { Log.e(TAG, "Could not find resource ", e); throw e; } ImageCardView cardView = new ImageCardView(context) { @Override public void setSelected(boolean selected) { super.setSelected(selected); if (mInfoField != null) { mInfoField.setBackground(sFocusedFadeMask); } } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); // Set the type and visibility of the info area. cardView.setCardType(BaseCardView.CARD_TYPE_INFO_OVER); cardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS); int CARD_WIDTH_PX = 160; mCardWidthDp = Helpers.convertPixelToDp(context, CARD_WIDTH_PX); int CARD_HEIGHT_PX = 120; mCardHeightDp = Helpers.convertPixelToDp(context, CARD_HEIGHT_PX); TextView subtitle = (TextView) cardView.findViewById(R.id.content_text); if (subtitle != null) { subtitle.setEllipsize(TextUtils.TruncateAt.END); } mInfoField = cardView.findViewById(R.id.info_field); if (mInfoField != null) { mInfoField.setBackground(sFocusedFadeMask); } return new ViewHolder(cardView); }
From source file:com.nttec.everychan.ui.ShareActivity.java
private void handleIntent(Intent intent) { ArrayAdapter<Pair<TabModel, SerializablePage>> adapter = new ArrayAdapter<Pair<TabModel, SerializablePage>>( this, 0) { private final int drawablePadding = (int) (getResources().getDisplayMetrics().density * 5 + 0.5f); @Override/*ww w . jav a 2 s.c om*/ public View getView(int position, View convertView, ViewGroup parent) { View view = convertView == null ? getLayoutInflater().inflate(android.R.layout.simple_list_item_1, parent, false) : convertView; TextView tv = (TextView) view.findViewById(android.R.id.text1); tv.setEllipsize(TextUtils.TruncateAt.END); tv.setSingleLine(); tv.setText(getItem(position).getLeft().title); tv.setCompoundDrawablesWithIntrinsicBounds(MainApplication.getInstance() .getChanModule(getItem(position).getLeft().pageModel.chanName).getChanFavicon(), null, null, null); tv.setCompoundDrawablePadding(drawablePadding); return view; } }; for (TabModel tab : MainApplication.getInstance().tabsState.tabsArray) { if (tab.type == TabModel.TYPE_NORMAL && tab.pageModel.type != UrlPageModel.TYPE_SEARCHPAGE) { SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } } if (adapter.getCount() == 0) { for (Database.HistoryEntry entity : MainApplication.getInstance().database.getHistory()) { try { TabModel tab = new TabModel(); tab.title = entity.title; tab.type = TabModel.TYPE_NORMAL; tab.webUrl = entity.url; tab.pageModel = UrlHandler.getPageModel(entity.url); tab.hash = ChanModels.hashUrlPageModel(tab.pageModel); SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } catch (Exception e) { Logger.e(TAG, e); } } if (adapter.getCount() == 0) { Toast.makeText(this, R.string.share_no_tabs, Toast.LENGTH_LONG).show(); finish(); return; } } if (PostingService.isNowPosting()) { Toast.makeText(this, R.string.posting_now_posting, Toast.LENGTH_LONG).show(); finish(); return; } selectedFile = null; if (intent != null) { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { File file = UriFileUtils.getFile(this, uri); if (file != null) { selectedFile = file; } } } if (selectedFile == null) { Toast.makeText(this, R.string.postform_cannot_attach, Toast.LENGTH_LONG).show(); finish(); return; } setListAdapter(adapter); }
From source file:net.lp.actionbarpoirot.helpers.ActivityHelperHoneycomb.java
/** {@inheritDoc} */ @Override//w ww . j a v a 2s.c o m public void enableActionBarTitleMarquee() { // Make title scrolling, a bit of a hack final TextView titleView = (TextView) mActivity.findViewById(actionBarTitleResId); if (titleView != null) { titleView.setEllipsize(TextUtils.TruncateAt.MARQUEE); titleView.setMarqueeRepeatLimit(-1); titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); titleView.requestFocus();// TODO: action bar title doesn't keep // scrolling after you've touched // something else. Should fix that. } // Also focus LeftNavBar, a bit of a hack too final View view = (mActivity.findViewById(leftNavActionBarResId)); if (view != null) { view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView title() { TextView title = new TextView(context); title.setSingleLine();/*from ww w.ja v a 2 s . c o m*/ title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getTitle()); title.setTextColor(getTitleColor()); title.setTextSize(getTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView subTitle() { TextView title = new TextView(context); title.setSingleLine();//from w w w .j a v a 2 s. c o m title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getSubTitle()); title.setTextColor(getSubTitleColor()); title.setTextSize(getSubTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:com.example.samsungmdm.MainActivity.java
public void onServerResponse(String response) { TextView serverResponseTextView = new TextView(this); serverResponseTextView.setHorizontallyScrolling(true); serverResponseTextView.setSingleLine(); serverResponseTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); serverResponseTextView.setFocusableInTouchMode(true); serverResponseTextView.setMarqueeRepeatLimit(1); serverResponseTextView.setFocusable(true); String myTime = java.text.DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()); serverResponseTextView.setText(myTime + " - " + response); mServerResponseLinearLayout.addView(serverResponseTextView, 0); //Parsing server response try {// w ww. ja va 2s . c o m parseServerResponse(new JSONObject(response)); } catch (JSONException e) { Log.e(TAG, "Invalid JSON response from the server"); e.printStackTrace(); } }
From source file:com.android.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w. ja va 2s . co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setSingleLine(); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setTextColor(Color.WHITE); int hpadding = (int) (TAB_VIEW_HORIZONTAL_PADDING_DIPS * getResources().getDisplayMetrics().density); int vpadding = (int) (TAB_VIEW_VERTICAL_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(hpadding, vpadding, hpadding, vpadding); return textView; }