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:com.ouyangzn.github.utils.UiUtils.java

public static TextView setCenterTitle(Toolbar toolbar, String title) {
    TextView titleView = new TextView(toolbar.getContext());
    titleView.setGravity(Gravity.CENTER);
    titleView.setTextAppearance(toolbar.getContext(), R.style.Toolbar_titleTextAppearance);
    titleView.setSingleLine();
    titleView.setEllipsize(TextUtils.TruncateAt.END);
    titleView.setText(title);//w w w .jav a2 s  .  co m
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    titleView.setLayoutParams(params);
    Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    lp.gravity = Gravity.CENTER;
    toolbar.addView(titleView, lp);
    return titleView;
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

/** Fix CR ALPS00839693,the "Phone" should be translated into Chinese */
public static void setAccountName(final TextView textView, final AccountWithDataSet account,
        Activity activity) {/*from w w  w . j a  va 2  s .c o  m*/
    if (AccountTypeUtils.ACCOUNT_NAME_LOCAL_PHONE.equals(account.name)) {
        textView.setText(activity.getString(R.string.contact_editor_prompt_one_account,
                activity.getString(R.string.account_phone_only)));
    } else {
        textView.setText(activity.getString(R.string.contact_editor_prompt_one_account, account.name));
    }
    // set ellip size for extra large font size
    textView.setSingleLine();
    textView.setEllipsize(TruncateAt.END);
}

From source file:ch.pantas.billsplitter.ui.FixedTabsView.java

private void addTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);/*from w  w  w.  j  a  v  a 2  s. com*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1f));

    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewPager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab, position);
}

From source file:ecust.news.myWidgetTabPageIndicator.java

public TextView decorateTextView(TextView textView) {
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Global.dimenConvert.dip2px(20));
    textView.setSingleLine();
    textView.setTextColor(textViewUnfocusedColor);
    textView.setFocusable(true);//from   w ww  .j av a 2  s . c  o  m
    textView.setClickable(true);

    //Padding
    final int paddingLeftRight = Global.dimenConvert.dip2px(12);
    final int paddingTop = Global.dimenConvert.dip2px(8);
    final int paddingBottom = Global.dimenConvert.dip2px(0);
    textView.setPadding(paddingLeftRight, paddingTop, paddingLeftRight, paddingBottom);

    return textView;
}

From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java

private TextView title() {
    TextView title = new TextView(context);
    title.setSingleLine();
    title.setEllipsize(TruncateAt.END);/*w ww .  j a  v  a2s .c om*/
    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();
    title.setEllipsize(TruncateAt.END);/*from   w ww. j av a 2  s  .  c  o m*/
    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.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//w ww. ja  va 2 s .  co m
        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: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 {//  ww w.  j  av  a 2  s  .c  om
        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   ww w .  j  a  va  2 s .  c o 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;
}

From source file:com.orange.ocara.ui.view.PagerSlidingTabStrip.java

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

    TextView tab = new TextView(getContext());
    tab.setText(title);/*from ww w.  j  a  va2  s.c  om*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setBackgroundResource(tabBackgroundResId);
    tab.setTextColor(tabTextColor);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    tab.setAllCaps(true);

    addTab(position, tab);
}