Example usage for android.view View findViewById

List of usage examples for android.view View findViewById

Introduction

In this page you can find the example usage for android.view View findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:Main.java

public static void setEditWeight(View view, int editId, float weight) {
    EditText editText = (EditText) view.findViewById(editId);

    editText.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, weight));

}

From source file:Main.java

public static boolean setText(View view, int resid, String text) {
    TextView mTextView = (TextView) view.findViewById(resid);
    if (mTextView != null) {
        mTextView.setText(text);// ww  w. ja  v a2  s.  co m
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean setText(View view, int id, int text) {
    TextView textView = (TextView) view.findViewById(id);
    if (textView == null)
        return false;

    textView.setText(text);//w  w w. j a  v a 2s.  co m
    return true;
}

From source file:Main.java

public static void setSpinnerSelectionWithString(View view, int spinnerId, String text) {
    Spinner spinner = (Spinner) view.findViewById(spinnerId);

    int count = spinner.getCount();
    for (int i = 0; i < count; i++) {
        if (spinner.getItemAtPosition(i).toString().equals(text))
            spinner.setSelection(i);/*www .  j  av a2 s . co m*/
    }
}

From source file:Main.java

public static String obterRadioText(View rootView, int radioCheckedId) {
    RadioButton selectedRadio = (RadioButton) rootView.findViewById(radioCheckedId);
    String radioMaterialText = selectedRadio.getText().toString();
    return radioMaterialText;
}

From source file:Main.java

public static boolean setText(View view, int id, String text) {
    TextView textView = (TextView) view.findViewById(id);
    if (textView == null)
        return false;

    textView.setText(text);/*from ww w .  j  a v a  2s .c  o m*/
    return true;
}

From source file:Main.java

static private String getMapperKeyFromUI(View view, int id) {
    String chr = ((EditText) (view.findViewById(id))).getText().toString();

    if (chr.length() != 1) {
        return "\n";
    } else {/*from   w  ww  .  j a v  a  2  s  .com*/
        return chr;
    }
}

From source file:Main.java

public static TextView setText(View parent, int textViewId, CharSequence text) {
    TextView textView = (TextView) parent.findViewById(textViewId);
    textView.setText(text);/*from ww  w.j  a  v  a 2 s. c om*/
    return textView;
}

From source file:Main.java

private static void createLink(View v, int id, String html) {
    TextView textView = (TextView) v.findViewById(id);
    textView.setClickable(true);//  w  ww  . j a  va 2  s  .c o  m
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(Html.fromHtml(html));
}

From source file:Main.java

public static void setText(View view, int resource, String text) {
    TextView textView = (TextView) view.findViewById(resource);
    textView.setText(text);//from www .  j  a  va2 s  . co  m
}