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

@android.view.RemotableViewMethod
public void setSingleLine(boolean singleLine) 

Source Link

Document

If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.

Usage

From source file:org.yasik.android.utils.conditions.RateAppDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(true);//from  w w w .j a va  2  s.  com
    // Inflate and build the dialog view.
    LayoutInflater inflater = getActivity().getLayoutInflater();
    LinearLayout dialogLayout = (LinearLayout) inflater.inflate(R.layout.rateapp_dialog_fragment, null);
    TextView textView = (TextView) dialogLayout.findViewById(R.id.rateapp_dialog_text);
    textView.setText(Html.fromHtml(getString(R.string.rateapp_dialog_text)));
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setSingleLine(false);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(dialogLayout).setTitle(R.string.rateapp_dialog_title)
            .setPositiveButton(R.string.rateapp_btn_title_rateme, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogRateNowClick(RateAppDialogFragment.this);
                }
            }).setNeutralButton(R.string.rateapp_btn_title_remind, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogRemindClick(RateAppDialogFragment.this);
                }
            }).setNegativeButton(R.string.rateapp_btn_title_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mListener.onDialogCancelClick(RateAppDialogFragment.this);
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    mListener.onDialogCancelClick(RateAppDialogFragment.this);
                }
            });
    return builder.create();
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

private static void setMaxLines(TextView view, int maxLines) {
    // setSingleLine must be called before setMaxLines because it resets maximum to
    // Integer.MAX_VALUE.
    if (maxLines == 1) {
        view.setSingleLine(true);
    } else {//from   www  . ja  v  a2  s.co  m
        view.setSingleLine(false);
        view.setMaxLines(maxLines);
    }
}

From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java

public void setToolbar(Toolbar toolbar) {
    setSupportActionBar(toolbar);//from w  w w  .  j  av  a 2 s .c  o  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.example.android.animationsdemo.GirdPagerSearchBarActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);
    LayoutInflater inflater = getLayoutInflater();
    // Inner ViewPager
    View headerview = inflater.inflate(R.layout.gridview_header, null);
    mInnerPager = (SlideFirstViewPager) headerview.findViewById(R.id.inner_pager);
    mPrev = (Button) findViewById(R.id.prev);
    mNext = (Button) findViewById(R.id.next);

    mHeaderGridView = (HeaderGridView) findViewById(R.id.gridView);
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    for (int i = 0; i < mPlaces.length; i++) {
        HashMap<String, String> item = new HashMap<String, String>();
        item.put("food", mPlaces[i]);
        item.put("place", mPlaces[i]);
        list.add(item);/*from  ww  w . j ava2s . c  o  m*/
    }
    SimpleAdapter adapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_2,
            new String[] { "food", "place" }, new int[] { android.R.id.text1, android.R.id.text2 });
    TextAdapter mAdapter = new TextAdapter();

    mPrev.setOnClickListener(this);
    mNext.setOnClickListener(this);

    mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager(), VIDEO_PATHS);
    mInnerPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            DKLog.d(TAG, Trace.getCurrentMethod() + position);
            mPagerAdapter.setFocus(position);
            invalidateOptionsMenu();
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    mInnerPager.setAdapter(mPagerAdapter);
    mInnerPager.setOffscreenPageLimit(NUM_PAGES);
    TextView mTextView = new TextView(getApplicationContext());
    mTextView.setText("OOOOOOOOOOOOOOOOOOOOO");
    mTextView.setTextSize(10);
    mTextView.setSingleLine(true);
    mHeaderGridView.addHeaderView(headerview, "ViewPager");
    mHeaderGridView.setAdapter(mAdapter);
    mHeaderGridView.setNumColumns(3);

    // Start Download
    //        for(int i = 0 ; i < VIDEO_PATHS.length ; i++) {
    //            DownloadService.downloadVideo(context, VIDEO_PATHS[i], new DownloadReceiver(new Handler()));
    //        }
}

From source file:org.openmrs.mobile.activities.dialog.CustomFragmentDialog.java

public TextView addTitleBar(String title) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_title_view_field, null);
    TextView textView = (TextView) field.findViewById(R.id.openmrsTitleView);
    textView.setText(title);/*from   www  . j av  a  2 s  .co  m*/
    textView.setSingleLine(true);
    mFieldsLayout.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    return textView;
}

From source file:org.openmrs.mobile.activities.dialog.CustomFragmentDialog.java

public TextView addTextField(String message) {
    LinearLayout field = (LinearLayout) mInflater.inflate(R.layout.openmrs_text_view_field, null);
    TextView textView = (TextView) field.findViewById(R.id.openmrsTextView);
    textView.setText(message);// w ww  .  j  av  a  2  s  .  c o m
    textView.setSingleLine(false);
    FontsUtil.setFont(textView, FontsUtil.OpenFonts.OPEN_SANS_ITALIC);
    mFieldsLayout.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return textView;
}

From source file:org.openremote.android.console.util.AsyncResourceLoader.java

/**
 * Update progress message in text./*from ww w  .  j a  v  a  2 s .co  m*/
 * 
 * @see android.os.AsyncTask#onProgressUpdate(Progress[])
 */
@Override
protected void onProgressUpdate(String... values) {
    RelativeLayout loadingView = (RelativeLayout) (activity.findViewById(R.id.welcome_view));
    if (loadingView == null) {
        return;
    }

    TextView loadingText = (TextView) (activity.findViewById(R.id.loading_text));
    loadingText.setText("loading " + values[0] + "...");
    loadingText.setEllipsize(TruncateAt.MIDDLE);
    loadingText.setSingleLine(true);
}

From source file:org.goodev.droidddle.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)}./*w ww.j a  v  a  2s . c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setSingleLine(true);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);
    textView.setTextColor(Color.WHITE);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.app.the.bunker.views.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)}./*  www.  j  a v a2 s  .c  o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    textView.setTypeface(Typeface.DEFAULT);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java

/**
 * Add header to ListView/* www  .j a v  a 2 s  .c om*/
 */
private View addListViewHeader() {
    TableRow row = (TableRow) View.inflate(getActivity(), R.layout.tablerow_income_vs_expenses, null);
    int[] ids = new int[] { R.id.textViewYear, R.id.textViewMonth, R.id.textViewIncome, R.id.textViewExpenses,
            R.id.textViewDifference };
    for (int id : ids) {
        TextView textView = (TextView) row.findViewById(id);
        textView.setTypeface(null, Typeface.BOLD);
        textView.setSingleLine(true);
    }
    getListView().addHeaderView(row);

    return row;
}