TextView setSingleLine - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setSingleLine method.

This code example shows how to use the following methods:setVisibility, setEllipsize, setSingleLine, setText, setTextAppearance
This code example shows how to use the following methods:setVisibility, setEllipsize, setGravity, setSingleLine, setText
     * Returns the text view for the app name, creating it if necessary. 
     */ 
    public void setNameText(CharSequence text) {
        if (!TextUtils.isEmpty(text)) {
            if (mNameTextView == null) {
                mNameTextView = new TextView(mContext);
                mNameTextView.setSingleLine(true);
                mNameTextView.setEllipsize(TruncateAt.END);
                mNameTextView.setTextAppearance(mContext, android.R.style.TextAppearance_Large);
                mNameTextView.setGravity(Gravity.CENTER_VERTICAL);
                addView(mNameTextView);
            } 
            mNameTextView.setText(text);
            mNameTextView.setVisibility(View.VISIBLE);
        } else { 
            if (mNameTextView != null) {
                mNameTextView.setVisibility(View.GONE);
            } 
        } 
    } 
8
CodeRank
This code example shows how to use the following methods:getTypeface, setEllipsize, setSingleLine, setTextAppearance, setTypeface
    /** 
     * Returns the text view for the data label, creating it if necessary. 
     */ 
    public TextView getLabelView() {
        if (mLabelView == null) {
            mLabelView = new TextView(mContext);
            mLabelView.setSingleLine(true);
            mLabelView.setEllipsize(TruncateAt.MARQUEE);
            mLabelView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
            mLabelView.setTypeface(mLabelView.getTypeface(), Typeface.BOLD);
            addView(mLabelView);
        } 
        return mLabelView;
    } 
 
    /** 
     * Adds or updates a text view for the data element. 
     */ 
    public void setData(char[] text, int size) {
        if (text == null || size == 0) {
7
CodeRank
This code example shows how to use the following methods:setLayoutParams, setSingleLine, setText, setTextColor, setTextSize
		LayoutParams textLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
		textLayoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
		textLayoutParams.setMargins(0, 0, 0, 0);
		textLayout.setLayoutParams(textLayoutParams);
 
		textView = new TextView(getContext());
		textView.setSingleLine(true);
		 
		LayoutParams textParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		textParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
		 
		if(this.text != null) {
			textView.setText(text);
		} 
	 
		if(textSize > 0) {
			textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
		} 
		else { 
			textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);

7
CodeRank
This code example shows how to use the following methods:setLayoutParams, setEllipsize, setGravity, setPadding, setSingleLine
            crumbView = view;
            data = tag;
        } 
 
        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;
        } 
 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setShadowLayer, setSingleLine, setTextColor
7
CodeRank
This code example shows how to use the following methods:setFocusable, setFocusableInTouchMode, setId, setLayoutParams, setPadding
     * @param toLeftOf Align the new textview to the right of the argument 
     * @return TextView The that represents the digit 
     */ 
    private TextView createTimerDigit(int id, int textSize, TextView toRigthOf) {
        // Create the TextView 
        TextView digit = new TextView(getContext());
        digit.setId(id);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        if (toRigthOf != null) {
            params.addRule(RelativeLayout.RIGHT_OF, toRigthOf.getId());
            params.addRule(RelativeLayout.ALIGN_BASELINE, toRigthOf.getId());
        } 
        digit.setLayoutParams(params);
        digit.setPadding(0, this.mPadding, 0, this.mPadding);
        digit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        digit.setTextColor(this.mColor);
        digit.setFocusable(false);
        digit.setFocusableInTouchMode(false);

7
CodeRank
This code example shows how to use the following methods:setGravity, setInputType, setLines, setSingleLine, setText
    protected void applyBinding() { 
        if (txtWidget != null) {
            txtWidget.setText(getCurrentValue());
        } 
        if (editWidget != null) {
            editWidget.setText(getCurrentValue());
        } 
    } 
 
    @Override 
    public View buildView(LayoutContext context, LayoutMode mode, Document doc,
            List<String> attributeNames, WidgetDefinition widgetDef) {
 
        super.buildView(context, mode, doc, attributeNames, widgetDef);
 
        Context ctx = context.getActivity();
 
        View view = null;
        if (mode == LayoutMode.VIEW) {
            txtWidget = new TextView(ctx);

7
CodeRank
This code example shows how to use the following methods:setGravity, setInputType, setLines, setSingleLine, setText
        } 
        if (htmlWidget != null) {
            htmlWidget.loadData(getCurrentValue().get(0), "text/html", "UTF-8");
        } 
        if (editWidget != null) {
            editWidget.setText(getCurrentValue().get(0));
        } 
    } 
 
    @Override 
    public View buildView(LayoutContext context, LayoutMode mode, Document doc,
            List<String> attributeNames, WidgetDefinition widgetDef) {
 
        super.buildView(context, mode, doc, attributeNames, widgetDef);
 
        Context ctx = context.getActivity();
 
        if (mode == LayoutMode.VIEW) {
            container = new LinearLayout(ctx);
            container.setOrientation(LinearLayout.VERTICAL);

7
CodeRank
This code example shows how to use the following methods:setLayoutParams, addTextChangedListener, setCursorVisible, setFilters, setGravity
        this.tvColorLabel.setLayoutParams(lp2);
 
        lp2 = new LinearLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        this.etColor = new EditText(getContext());
        this.etColor.setSingleLine();
        this.etColor.setGravity(Gravity.TOP | Gravity.LEFT);
        this.etColor.setCursorVisible(true);
        this.etColor.setImeOptions(
                EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_FULLSCREEN);
        this.etColor.setInputType(
                InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        this.etColor.setLayoutParams(lp2);
        InputFilter[] filters = new InputFilter[2];
        filters[0] = new InputFilter.LengthFilter(8);
        filters[1] = new InputFilter() {
            @Override 
            public CharSequence filter(CharSequence source, int start,
                    int end, Spanned dest, int dstart, int dend) {

6
CodeRank

Related TextView setSingleLine Questions & Answers:

setSingleLine Method Overview
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
See Code Examples for other Android TextView Methods: