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:tbs.simplecars.ui.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    final TextView tab = new TextView(getContext());
    tab.setText(title);//from  w  w  w . j av  a 2s  . co m
    tab.setTextSize(18);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    addTab(position, tab);
}

From source file:com.github.johnpersano.supertoasts.demo.views.TabStrip.java

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

    TextView tab = new TextView(getContext());
    tab.setText(title);/*  w  ww. j  a  v a2 s. c  o  m*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setAllCaps(true);

    addTab(position, tab);
}

From source file:com.vuze.android.remote.fragment.OpenOptionsGeneralFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    FragmentActivity activity = getActivity();
    Intent intent = activity.getIntent();

    if (AndroidUtils.DEBUG) {
        Log.d(TAG, activity + "] onCreateview " + this);
    }//from w  ww.  j  a  v  a 2 s  .c o  m

    final Bundle extras = intent.getExtras();
    if (extras == null) {
        Log.e(TAG, "No extras!");
    } else {

        String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY);
        if (remoteProfileID != null) {
            sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, activity);
        }

        torrentID = extras.getLong("TorrentID");
    }

    if (activity instanceof TorrentOpenOptionsActivity) {
        ourActivity = (TorrentOpenOptionsActivity) activity;
    }

    topView = inflater.inflate(R.layout.frag_openoptions_general, container, false);

    ImageButton btnEditDir = (ImageButton) topView.findViewById(R.id.openoptions_btn_editdir);
    ImageButton btnEditName = (ImageButton) topView.findViewById(R.id.openoptions_btn_editname);

    tvName = (TextView) topView.findViewById(R.id.openoptions_name);
    tvSaveLocation = (TextView) topView.findViewById(R.id.openoptions_saveloc);
    tvFreeSpace = (TextView) topView.findViewById(R.id.openoptions_freespace);

    CompoundButton btnPositionLast = (CompoundButton) topView.findViewById(R.id.openoptions_sw_position);

    CompoundButton btnStateQueued = (CompoundButton) topView.findViewById(R.id.openoptions_sw_state);

    if (ourActivity != null) {
        if (btnPositionLast != null) {
            btnPositionLast.setChecked(ourActivity.isPositionLast());
            btnPositionLast.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    ourActivity.setPositionLast(isChecked);
                }
            });
        }
        if (btnStateQueued != null) {
            btnStateQueued.setChecked(ourActivity.isStateQueued());
            btnStateQueued.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    ourActivity.setStateQueued(isChecked);
                }
            });
        }
    }

    final Map<?, ?> torrent = sessionInfo.getTorrent(torrentID);

    if (torrent == null) {
        getActivity().finish();
        VuzeEasyTracker.getInstance(getActivity()).logError("Torrent doesn't exist", TAG);
        return topView;
    }

    if (torrent.containsKey(TransmissionVars.FIELD_TORRENT_DOWNLOAD_DIR)) {
        updateFields(torrent);
    } else {
        sessionInfo.executeRpc(new RpcExecuter() {
            @Override
            public void executeRpc(TransmissionRPC rpc) {
                rpc.getTorrent(TAG, torrentID,
                        Collections.singletonList(TransmissionVars.FIELD_TORRENT_DOWNLOAD_DIR),
                        new TorrentListReceivedListener() {

                            @Override
                            public void rpcTorrentListReceived(String callID, List<?> addedTorrentMaps,
                                    List<?> removedTorrentIDs) {
                                AndroidUtils.runOnUIThread(OpenOptionsGeneralFragment.this, new Runnable() {
                                    @Override
                                    public void run() {
                                        updateFields(torrent);
                                    }
                                });
                            }
                        });
            }
        });
    }

    if (btnEditDir != null) {
        btnEditDir.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Map<?, ?> torrent = sessionInfo.getTorrent(torrentID);
                DialogFragmentMoveData.openMoveDataDialog(torrent, sessionInfo, getFragmentManager());
            }
        });
    }

    if (btnEditName != null) {
        if (sessionInfo.getSupportsTorrentRename()) {
            btnEditName.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Builder builder = new AlertDialog.Builder(getActivity());
                    final TextView textView = new EditText(getActivity());
                    textView.setText(tvName.getText());
                    textView.setSingleLine();

                    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
                        builder.setInverseBackgroundForced(true);
                    }

                    builder.setView(textView);
                    builder.setTitle(R.string.change_name_title);
                    builder.setMessage(R.string.change_name_message);
                    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            final String newName = textView.getText().toString();
                            tvName.setText(newName);
                            sessionInfo.executeRpc(new RpcExecuter() {

                                @Override
                                public void executeRpc(TransmissionRPC rpc) {
                                    rpc.setDisplayName(TAG, torrentID, newName);
                                }
                            });
                        }
                    });
                    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });
                    builder.create().show();
                }
            });
        } else {
            btnEditName.setVisibility(View.GONE);
        }
    }

    return topView;
}

From source file:com.quran.labs.androidquran.widgets.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 w w .j a  v  a2s .c  o  m*/
 */
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();
    textView.setTextColor(mUnselectedTabColor);

    // If we're running on Honeycomb or newer, then we can use the Theme's
    // selectableItemBackground to ensure that the View has a pressed state
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = mTabPadding;
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:larry.baby.rain.common.view.TabPageIndicator.java

private void addTab(CharSequence text, int index) {
    Context context = getContext();
    DisplayMetrics dm = context.getResources().getDisplayMetrics();

    int padX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, dm);
    int padY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, dm);

    TextView tabView = new TextView(context);
    tabView.setBackgroundResource(R.drawable.vpi__tab_indicator);
    tabView.setPadding(padX, padY, padX, padY);
    tabView.setGravity(Gravity.CENTER);// w ww.j  a  v a  2 s .  co  m
    tabView.setTextColor(0xfff3f3f3);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    tabView.setTypeface(tabView.getTypeface(), Typeface.BOLD);
    tabView.setSingleLine();
    tabView.setTag(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this);
    tabView.setText(text);

    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
}

From source file:org.uguess.android.sysinfo.SiragonInfo.java

private void fixTextView(View view) {
    if (view instanceof TextView) {
        TextView tv = (TextView) view;
        tv.setSingleLine();
        Util.setAllCaps(tv, false);
    } else if (view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) view;

        for (int i = 0, size = vg.getChildCount(); i < size; i++) {
            fixTextView(vg.getChildAt(i));
        }// ww  w .j  av  a2 s .c o  m
    }
}

From source file:com.wunding.mlplayer.ui.PagerSlidingTabStrip.java

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

    TextView tab = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.radio_group, null);

    tab.setText(title);//  ww w.  ja  v  a  2s.c  o  m
    tab.setSingleLine();
    tab.setWidth(tabWidth);
    addTab(position, tab);
}

From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java

private void addTextTab(final int position, final String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);/*from w ww .  ja  v  a2s  .  c  o m*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setFocusable(true);
    //tab.setOnClickListener(new OnClickListener() {
    //    @Override public void onClick(View v) {
    //        pager.setCurrentItem(position);
    //        v.setSelected(true);
    //    }
    //});

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
            v.setSelected(true);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tab.setBackgroundResource(tabBackgroundResId);
    tab.setTextColor(mTabTextColor);
    tab.setTextSize(tabTextSize);
    //tab.setTypeface(tabTypeface, tabTypefaceStyle);

    tab.setSelected(position == 0);

    // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
    // pre-ICS-build
    if (textAllCaps) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            tab.setAllCaps(true);
        } else {
            tab.setText(tab.getText().toString().toUpperCase(locale));
        }
    }

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.hobby.uiframework.widget.PagerSlidingTab.java

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

    TextView tab = new TextView(getContext());
    tab.setText(title);//from  w ww .j a  v a 2  s. c o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTag(title + position);
    addTab(position, tab);
}

From source file:ar.com.xpasta.Controls.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);/*from  w w w .ja  va  2s .co m*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    addTab(position, tab);
}