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 String get_TextView_string(Activity activity, int what) {
    TextView ans = (TextView) activity.findViewById(what);
    String str = (String) ans.getText();
    return str;/*from   ww  w. j  a  va 2 s .c o  m*/
}

From source file:Main.java

public static <T extends View> T findViewById(Activity activity, @IdRes int id) {
    T v = (T) activity.findViewById(id);
    return v;//from w w w  .j  a  v a2  s. c  o  m
}

From source file:Main.java

public static void addViewToRoot(Activity act, View v) {
    ViewGroup root = (FrameLayout) act.findViewById(android.R.id.content);
    root = (ViewGroup) root.getChildAt(0);
    ViewGroup.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    root.addView(v, params);//from  w  ww  .ja  v a  2s. c o m
}

From source file:Main.java

public static boolean isDualPane(Activity activity, int viewIdToLookForInActivity) {
    View view = activity.findViewById(viewIdToLookForInActivity);
    return view != null && view.getVisibility() == View.VISIBLE;
}

From source file:Main.java

public static <T> T findViewById(Activity activity, @IdRes int viewID) {
    return findViewById(activity.findViewById(android.R.id.content), viewID);
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T extends View> T getView(Activity parent, int viewId) {
    return (T) checkView(parent.findViewById(viewId));
}

From source file:Main.java

public static void setText(Activity activity, int textViewId, String text) {
    ((TextView) activity.findViewById(textViewId)).setText(text);
}

From source file:Main.java

public static void displayText(Activity activity, int id, String text) {
    TextView tv = (TextView) activity.findViewById(id);
    tv.setText(text);/*  w  ww .ja v  a 2 s . co m*/
}

From source file:Main.java

public static void setCBChecked(Activity activity, int id, boolean value) {
    CheckBox cb = (CheckBox) activity.findViewById(id);
    cb.setChecked(value);//  w  ww.  ja v  a 2s . c o m
}

From source file:org.simple.injector.util.ViewFinder.java

public static <T extends View> T findViewById(Activity act, int id) {
    return (T) act.findViewById(id);
}