Example usage for android.widget TextView getText

List of usage examples for android.widget TextView getText

Introduction

In this page you can find the example usage for android.widget TextView getText.

Prototype

@ViewDebug.CapturedViewProperty
public CharSequence getText() 

Source Link

Document

Return the text that TextView is displaying.

Usage

From source file:info.staticfree.android.units.UnitUsageDBHelper.java

/**
 * @param otherEntry/*from ww w  .  j  av a 2 s . c o  m*/
 * @return
 */
private synchronized static String[] getConformingSelectionArgs(TextView otherEntry) {
    final String otherEntryText = otherEntry.getText().toString();
    if (otherEntryText.length() > 0) {
        if (otherEntryText.toString().equals(cachedEntryText)) {
            return cachedEntryFprintArgs;
        }
        try {
            final String[] conformingSelectionArgs = {
                    ValueGui.getFingerprint(ValueGui.fromUnicodeString(ValueGui.closeParens(otherEntryText))) };
            cachedEntryText = otherEntryText;
            cachedEntryFprintArgs = conformingSelectionArgs;
            return conformingSelectionArgs;
        } catch (final EvalError e) {
            return null;
        }
    }
    return null;
}

From source file:com.alainesp.fan.sanderson.MainActivity.java

/**
 * Set the badge number to all menu items visible
 *///  www.  j ava2 s  .c o  m
private static void setBadgesNumberUI() {
    if (navigationView != null) {
        NavigationMenuView v = (NavigationMenuView) navigationView.getChildAt(0);
        Menu drawerMenu = navigationView.getMenu();

        if (v != null)
            // Iterate all children
            for (int childIndex = 0; childIndex < v.getChildCount(); childIndex++) {
                View v1 = v.getChildAt(childIndex);
                if (v1 instanceof NavigationMenuItemView) {
                    TextView mTextView = (TextView) ((NavigationMenuItemView) v1).getChildAt(0);
                    if (mTextView != null) {
                        // Get the menu index
                        Integer menuIndex = reverseMenuText.get(mTextView.getText().toString());
                        if (menuIndex != null && menuIndex < badgeNumbers.length) {
                            Drawable numberText = null;
                            if (badgeNumbers[menuIndex] > 0) {
                                int height = mTextView.getHeight();
                                numberText = new TextDrawable(badgeNumbers[menuIndex], mTextView.getTextSize(),
                                        mTextView.getCurrentTextColor(), height);
                                numberText.setBounds(0, 0, height, height);
                            }

                            // Similar to NavigationMenuItemView.setIcon
                            Drawable icon = drawerMenu.getItem(menuIndex).getIcon();
                            Drawable.ConstantState state = icon.getConstantState();
                            icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate();
                            int mIconSize = navigationView.getContext().getResources().getDimensionPixelSize(
                                    android.support.design.R.dimen.design_navigation_icon_size);
                            icon.setBounds(0, 0, mIconSize, mIconSize);
                            DrawableCompat.setTintList(icon, navigationView.getItemIconTintList());
                            TextViewCompat.setCompoundDrawablesRelative(mTextView, icon, null, numberText,
                                    null);
                        }
                    }
                }
            }
    }
}

From source file:com.dmbstream.android.util.Util.java

private static void findNotificationTextColors(ViewGroup group, String title, String content) {
    for (int i = 0; i < group.getChildCount(); i++) {
        if (group.getChildAt(i) instanceof TextView) {
            TextView textView = (TextView) group.getChildAt(i);
            String text = textView.getText().toString();
            if (title.equals(text)) {
                NOTIFICATION_TEXT_COLORS.setFirst(textView.getTextColors().getDefaultColor());
            } else if (content.equals(text)) {
                NOTIFICATION_TEXT_COLORS.setSecond(textView.getTextColors().getDefaultColor());
            }/* ww  w.j av a 2  s . c  om*/
        } else if (group.getChildAt(i) instanceof ViewGroup)
            findNotificationTextColors((ViewGroup) group.getChildAt(i), title, content);
    }
}

From source file:com.cw.litenote.note.Note.java

/** Set outline for selected view mode
*
*   Determined by view mode: all, picture, text
*
*   Controlled factor:/*from www . j a va2  s .  com*/
*   - action bar: hide, show
*   - full screen: full, not full
*/
public static void setOutline(AppCompatActivity act) {
    // Set full screen or not, and action bar
    if (isViewAllMode() || isTextMode()) {
        Util.setFullScreen_noImmersive(act);
        if (act.getSupportActionBar() != null)
            act.getSupportActionBar().show();
    } else if (isPictureMode()) {
        Util.setFullScreen(act);
        if (act.getSupportActionBar() != null)
            act.getSupportActionBar().hide();
    }

    // renew pager
    showSelectedView();

    LinearLayout buttonGroup = (LinearLayout) act.findViewById(R.id.view_button_group);
    // button group
    if (Note.isPictureMode())
        buttonGroup.setVisibility(View.GONE);
    else
        buttonGroup.setVisibility(View.VISIBLE);

    TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title);
    // audio title
    if (!Note.isPictureMode()) {
        if (!Util.isEmptyString(audioTitle.getText().toString()))
            audioTitle.setVisibility(View.VISIBLE);
        else
            audioTitle.setVisibility(View.GONE);
    }

    // renew options menu
    act.invalidateOptionsMenu();
}

From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.WebViewFragment.java

/**
 * loads a custom url from the url bar//  ww  w.  ja  v  a 2  s . c  o  m
 * @param v
 * @param actionId
 * @return
 */
@OnEditorAction(R.id.website_input)
boolean onEditorAction(TextView v, int actionId) {

    if (URLUtil.isValidUrl(v.getText().toString()))
        webView.loadUrl(v.getText().toString());
    else
        Toast.makeText(getActivity(), getString(R.string.web_error_toast), Toast.LENGTH_SHORT).show();
    Util.hideKeyboard(websiteInput, getActivity());
    return true;
}

From source file:com.androidformenhancer.internal.impl.DatePickerDialogSupportFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();/*from w  ww  .j a v a 2  s  .  co  m*/
    int id = args.getInt(ARG_TARGET_VIEW_RES_ID);
    View v = getActivity().findViewById(id);
    if (v == null || !(v instanceof TextView)) {
        throw new IllegalArgumentException("Target view must be valid TextView: " + v);
    }
    final TextView tv = (TextView) v;
    if (TextUtils.isEmpty(tv.getText())) {
        int defaultMessageId = args.getInt(ARG_DEFAULT_MESSAGE_RES_ID);
        tv.setText(getActivity().getString(defaultMessageId));
    }

    DatePickerDialog.OnDateSetListener callBack = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar c = Calendar.getInstance(Locale.getDefault());
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, monthOfYear);
            c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            tv.setText(DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(c.getTime()));
        }
    };
    Calendar c = Calendar.getInstance();
    final Dialog dialog = new DatePickerDialog(getActivity(), callBack, c.get(Calendar.YEAR),
            c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)) {
    };
    return dialog;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void applyParagraphSpacing(TextView textView, float multiplier) {
    final SpannableStringBuilder builder = SpannableStringBuilder.valueOf(textView.getText());
    int prevLineBreak, currLineBreak = 0;
    for (int i = 0, j = builder.length(); i < j; i++) {
        if (builder.charAt(i) == '\n') {
            prevLineBreak = currLineBreak;
            currLineBreak = i;//  w  ww  . j a va  2  s  .c o m
            if (currLineBreak > 0) {
                builder.setSpan(new ParagraphSpacingSpan(multiplier), prevLineBreak, currLineBreak,
                        Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            }
        }
    }
    textView.setText(builder);
}

From source file:com.google.android.gms.samples.plus.MomentActivity.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    TextView textView = (TextView) view;
    String momentType = (String) textView.getText();
    String targetUrl = MomentUtil.MOMENT_TYPES.get(momentType);

    ItemScope target = new ItemScope.Builder().setUrl(targetUrl).build();

    Moment.Builder momentBuilder = new Moment.Builder();
    momentBuilder.setType("http://schemas.google.com/" + momentType);
    momentBuilder.setTarget(target);//from  w w w. ja  v  a2  s.com

    ItemScope result = MomentUtil.getResultFor(momentType);
    if (result != null) {
        momentBuilder.setResult(result);
    }

    // Resolve the connection status, and write the moment once PlusClient is connected.
    mPendingMoments.add(momentBuilder.build());
    mPlusClientFragment.signIn(REQUEST_CODE_PLUS_CLIENT_FRAGMENT);
}

From source file:com.aqnote.app.wifianalyzer.about.AboutActivity.java

private void setApplicationName() {
    Configuration configuration = MainContext.INSTANCE.getConfiguration();
    if (configuration != null && configuration.isDevelopmentMode()) {
        TextView textView = (TextView) findViewById(R.id.about_app_name);
        textView.setText(textView.getText() + " " + MainActivity.WI_FI_ANALYZER_BETA);
    }//from  w ww . ja va 2s  .  c o  m
}

From source file:com.codinguser.android.contactpicker.ContactDetailsFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    TextView tv = (TextView) v.findViewById(R.id.phone_number);
    String number = tv.getText().toString();
    String name = mDisplayName.getText().toString();

    mContactsListener.onContactNumberSelected(number, name);
}