Example usage for android.widget TextView getId

List of usage examples for android.widget TextView getId

Introduction

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

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:com.fbartnitzek.tasteemall.addentry.CompletionUserAdapter.java

@Override
public void setViewText(TextView v, String text) {
    switch (v.getId()) {
    case R.id.list_item_user_name:
        v.setText(text);//from  www.  ja v a2  s.com
        v.setContentDescription(mActivity.getString(R.string.a11y_user_name, text));
        break;
    default:
        super.setViewText(v, text);
    }
}

From source file:com.fbartnitzek.tasteemall.addentry.CompletionProducerAdapter.java

@Override
public void setViewText(TextView v, String text) {
    Log.v(LOG_TAG,//w  ww.j av  a 2 s .  c o  m
            "setViewText, hashCode=" + this.hashCode() + ", " + "v = [" + v + "], text = [" + text + "]");
    if (v.getId() == R.id.list_item_location_name) {
        v.setText(mActivity.getString(R.string.completion_subentry_formatting, text));
        v.setContentDescription(mActivity.getString(R.string.a11y_producer_location, text));
    } else if (v.getId() == R.id.list_item_producer_name) {
        v.setText(text);
        v.setContentDescription(mActivity.getString(R.string.a11y_producer_name, text));
    }
}

From source file:com.fbartnitzek.tasteemall.addentry.CompletionDrinkAdapter.java

@Override
public void setViewText(TextView v, String text) {
    //        Log.v(LOG_TAG, "setViewText, hashCode=" + this.hashCode() + ", " + "v = [" + v + "], text = [" + text + "]");
    switch (v.getId()) {
    case R.id.list_item_producer_name:
        v.setText(mActivity.getString(R.string.completion_subentry_formatting, text));
        v.setContentDescription(mActivity.getString(R.string.a11y_producer_name, text));
        break;/*ww w.j av  a  2 s.  c o  m*/
    case R.id.list_item_drink_name:
        v.setText(text);
        v.setContentDescription(mActivity.getString(R.string.a11y_drink_name, text));
        break;
    case R.id.list_item_drink_type:
        v.setText(mActivity.getString(R.string.completion_prefix_formatting, text));
        v.setContentDescription(mActivity.getString(R.string.a11y_drink_type,
                mActivity.getString(Utils.getReadableDrinkNameId(mContext, text))));
        break;
    default:
        super.setViewText(v, text);
    }
}

From source file:com.github.tbouron.shakedetector.example.MainActivity.java

private void updateSeekBarLabel(TextView view, String textToAppend) {
    String label = "";
    if (view.getId() == R.id.sensibility_label) {
        label = getString(R.string.label_sensibility, textToAppend);
    }/*w  ww  .  java2s.c  om*/
    if (view.getId() == R.id.shake_number_label) {
        label = getString(R.string.label_shake_number, textToAppend);
    }
    view.setText(label);
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public void onClick(View arg0) {
    TextView v = (TextView) arg0;

    if (v.getId() == R.id.sharp) {
        sharp = !sharp;/*from   w  ww. j a  v a  2  s .co m*/
        int pos = 9;
        if (actualFreqView != null && !sharp) {
            pos = getTone(actualFreqView.getId()).getTonePos();
            v.setTextColor(getView().getResources().getColor(R.color.blue));
        } else if (actualFreqView != null && sharp) {
            // FIXME: Use only one method to get pos.

            pos = (getTone(actualFreqView.getId()).getTonePos() + 1) % 12;
            v.setTextColor(Color.RED);
        } else if (actualFreqView == null && sharp) {
            v.setTextColor(Color.RED);
        } else if (actualFreqView == null && !sharp) {
            v.setTextColor(getView().getResources().getColor(R.color.blue));
        }

        int baseFreq = SharedPref.getBaseFreq(getActivity());
        float freq = baseFreq * Tones.freqCoefs[pos];
        input.setText(String.format("%.2f", freq));

        pl.setFreq(freq);
    } else {
        if (actualFreqView != null) {
            actualFreqView.setTextColor(getView().getResources().getColor(R.color.blue));
        }

        actualFreqView = v;

        // Set frequency coefficient accordingly.
        int freqCoefPosition = getTone(v.getId()).getTonePos();
        freqCoefPosition = sharp ? (freqCoefPosition + 1) % 12 : freqCoefPosition;

        int baseFreq = SharedPref.getBaseFreq(getActivity());
        float freq = baseFreq * Tones.freqCoefs[freqCoefPosition];

        input.setText(String.format("%.2f", freq));
        pl.setFreq(freq);
        if (!pl.isPlay()) {
            pl.togglePlay();
        }

        v.setTextColor(Color.RED);
    }

    AnimationSet push = (AnimationSet) AnimationUtils.loadAnimation(v.getContext(), R.anim.push);
    v.startAnimation(push);
}

From source file:org.musicbrainz.mobile.activity.BarcodeSearchActivity.java

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (v.getId() == R.id.barcode_search && actionId == EditorInfo.IME_NULL) {
        doSearch();//from   ww  w  . jav  a  2s .  c  om
    }
    return false;
}

From source file:ca.mymenuapp.ui.activities.MainActivity.java

@OnClick({ R.id.sort_distance, R.id.sort_rating, R.id.sort_cuisine })
void onSortButtonClicked(TextView button) {
    switch (button.getId()) {
    case R.id.sort_distance:
        sortRestaurants(new Comparator<Restaurant>() {
            @Override//from  w w  w .j  a v a  2 s  . c  om
            public int compare(Restaurant lhs, Restaurant rhs) {
                return Double.compare(SphericalUtil.computeDistanceBetween(lastLatLng, lhs.getPosition()),
                        SphericalUtil.computeDistanceBetween(lastLatLng, rhs.getPosition()));
            }
        });
        break;
    case R.id.sort_rating:
        sortRestaurants(new Comparator<Restaurant>() {
            @Override
            public int compare(Restaurant lhs, Restaurant rhs) {
                // sort descending
                return Double.compare(rhs.rating, lhs.rating);
            }
        });
        break;
    case R.id.sort_cuisine:
        sortRestaurants(new Comparator<Restaurant>() {
            @Override
            public int compare(Restaurant lhs, Restaurant rhs) {
                return lhs.category.compareTo(rhs.category);
            }
        });
        break;
    default:
        throw new IllegalArgumentException("Not handled!");
    }
}

From source file:com.androidinspain.deskclock.timer.TimerSetupView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mTimeView = (TextView) findViewById(R.id.timer_setup_time);
    mDeleteView = findViewById(R.id.timer_setup_delete);
    mDividerView = findViewById(R.id.timer_setup_divider);
    mDigitViews = new TextView[] { (TextView) findViewById(R.id.timer_setup_digit_0),
            (TextView) findViewById(R.id.timer_setup_digit_1),
            (TextView) findViewById(R.id.timer_setup_digit_2),
            (TextView) findViewById(R.id.timer_setup_digit_3),
            (TextView) findViewById(R.id.timer_setup_digit_4),
            (TextView) findViewById(R.id.timer_setup_digit_5),
            (TextView) findViewById(R.id.timer_setup_digit_6),
            (TextView) findViewById(R.id.timer_setup_digit_7),
            (TextView) findViewById(R.id.timer_setup_digit_8),
            (TextView) findViewById(R.id.timer_setup_digit_9), };

    // Tint the divider to match the disabled control color by default and used the activated
    // control color when there is valid input.
    final Context dividerContext = mDividerView.getContext();
    final int colorControlActivated = ThemeUtils.resolveColor(dividerContext, R.attr.colorControlActivated);
    final int colorControlDisabled = ThemeUtils.resolveColor(dividerContext, R.attr.colorControlNormal,
            new int[] { ~android.R.attr.state_enabled });
    ViewCompat.setBackgroundTintList(mDividerView,
            new ColorStateList(new int[][] { { android.R.attr.state_activated }, {} },
                    new int[] { colorControlActivated, colorControlDisabled }));
    ViewCompat.setBackgroundTintMode(mDividerView, PorterDuff.Mode.SRC);

    // Initialize the digit buttons.
    final UiDataModel uidm = UiDataModel.getUiDataModel();
    for (final TextView digitView : mDigitViews) {
        final int digit = getDigitForId(digitView.getId());
        digitView.setText(uidm.getFormattedNumber(digit, 1));
        digitView.setOnClickListener(this);
    }//w w  w  . j a  va  2 s .  co  m

    mDeleteView.setOnClickListener(this);
    mDeleteView.setOnLongClickListener(this);

    updateTime();
    updateDeleteAndDivider();
}

From source file:com.microsoft.graph.snippets.SnippetDetailFragment.java

private void clipboard(TextView tv) {
    // which view are we copying to the clipboard?
    int which;//from  ww  w . j  av a2 s.c o m

    switch (tv.getId()) {
    case txt_request_url: // the url field
        which = code_snippet;
        break;

    case txt_response_body: // the response body
        which = raw_object;
        break;

    default:
        which = UNSET; // don't assign a prefix
    }

    // if we know which view we're copying, prefix it with useful info
    String what = which == UNSET ? "" : getString(which) + " ";

    // concat the clipboard data to this String
    what += getString(clippy);

    // inform the user that data was added to the clipboard
    Toast.makeText(getActivity(), what, Toast.LENGTH_SHORT).show();

    // depending on our API, do it one way or another...
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // old way
        ClipboardManager clipboardManager = (ClipboardManager) getActivity()
                .getSystemService(Context.CLIPBOARD_SERVICE);
        clipboardManager.setText(tv.getText());
    } else {
        clipboard11(tv);
    }
}

From source file:com.androidformenhancer.helper.FormHelper.java

/**
 * Sets the error icon and popup window to the specified TextView or
 * EditText.<br>//from  ww w . j  ava  2 s  .  c  o m
 * Before calling this, you must call {@linkplain #validate()} or
 * {@linkplain #validateText(int)} to get validation result.
 *
 * @param result   validation result
 * @param textView TextView or EditText object which you want to set error
 */
public void setErrorToTextView(final ValidationResult result, final TextView textView) {
    if (mValidationErrorIconEnabled) {
        int id = textView.getId();
        if (result.hasErrorFor(id)) {
            textView.setError(StringUtils.serialize(result.getErrorsFor(id)), mIconError);
            textView.setCompoundDrawables(null, null, mIconError, null);
        } else {
            textView.setCompoundDrawables(null, null, mIconOk, null);
        }
    }
}