Example usage for android.app Activity findViewById

List of usage examples for android.app Activity findViewById

Introduction

In this page you can find the example usage for android.app Activity findViewById.

Prototype

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

Source Link

Document

Finds a view that was identified by the android:id XML attribute that was processed in #onCreate .

Usage

From source file:Main.java

public static EditText getEditText(Activity activity, int rid) {
    return (EditText) activity.findViewById(rid);
}

From source file:Main.java

public static boolean getCBChecked(Activity activity, int id) {
    CheckBox cb = (CheckBox) activity.findViewById(id);
    return cb.isChecked();
}

From source file:Main.java

public static String getText(Activity activity, int id) {
    EditText et = (EditText) activity.findViewById(id);
    return et.getText().toString();
}

From source file:Main.java

public static <T extends View> T lfind(Activity aty, int id, Class<T> clazz) {
    View view = aty.findViewById(id);
    return clazz.cast(view);
}

From source file:Main.java

public static void removeView(Activity act, View v) {
    ViewGroup root = (ViewGroup) act.findViewById(android.R.id.content);
    root = (ViewGroup) root.getChildAt(0);
    root.removeView(v);//  w w  w  . java  2s .c o m
}

From source file:Main.java

public static void setTextInView(int viewId, String val, Activity activity) {
    TextView textView = (TextView) activity.findViewById(viewId);
    if (textView != null)
        textView.setText(val);
}

From source file:Main.java

public static void populateTextView(int textViewId, String value, Activity activity) {
    TextView textView = (TextView) activity.findViewById(textViewId);

    textView.setText(value);/*from   w  w  w.j  a  va2s.  co m*/
}

From source file:Main.java

public static TextView get_TextView(Activity activity, int what) {
    TextView ans = (TextView) activity.findViewById(what);
    return ans;/*  w  w  w  .j  av a  2s.co m*/
}

From source file:Main.java

public static String get_editText_string(Activity activity, int what) {
    EditText ans = (EditText) activity.findViewById(what);
    String str = ans.getText().toString();
    return str;/*from w  w w .j  a  v  a2 s  .c o  m*/
}

From source file:Main.java

public static void HideView(Activity activity, int viewId, int mode) {
    View view = activity.findViewById(viewId);
    if (view != null) {
        view.setVisibility(mode);/*from w  w  w. j  a v  a 2  s  .c o m*/
    }
}