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:com.ayuget.redface.ui.misc.SnackbarHelper.java

public static Snackbar make(Activity targetActivity, CharSequence textRes) {
    return make(targetActivity.findViewById(android.R.id.content), textRes, false);
}

From source file:com.ayuget.redface.ui.misc.SnackbarHelper.java

public static Snackbar makeError(Activity targetActivity, CharSequence textRes) {
    return make(targetActivity.findViewById(android.R.id.content), textRes, true);
}

From source file:com.ayuget.redface.ui.misc.SnackbarHelper.java

public static Snackbar make(Activity targetActivity, @StringRes int textRes) {
    return make(targetActivity.findViewById(android.R.id.content), textRes, false);
}

From source file:com.ayuget.redface.ui.misc.SnackbarHelper.java

public static Snackbar makeError(Activity targetActivity, @StringRes int textRes) {
    return make(targetActivity.findViewById(android.R.id.content), textRes, true);
}

From source file:Main.java

public static View getRootView(Activity activity) {
    View view1 = activity.getWindow().getDecorView().findViewById(android.R.id.content);
    View view2 = activity.findViewById(android.R.id.content);
    View view3 = activity.findViewById(android.R.id.content).getRootView();

    return view2;
}

From source file:Main.java

public static View getRootView(Activity context) {
    if (context == null)
        return null;
    ViewGroup content = (ViewGroup) context.findViewById(android.R.id.content);
    if (content != null) {
        return content.getChildAt(0);
    }//ww w  . j a  v a 2  s.co m
    return null;
}

From source file:net.xkor.genaroid.Genaroid.java

public static void bind(@NonNull Activity activity) {
    bind(activity, activity.findViewById(android.R.id.content));
}

From source file:Main.java

public static View findActionBarContainer(Activity activity) {
    int id = activity.getResources().getIdentifier("action_bar_container", "id", activity.getPackageName());
    return activity.findViewById(id);
}

From source file:Main.java

public static void bindOnClick(final Activity context, int viewId, final Class<?> clazz, final int flags) {
    View view = (View) context.findViewById(viewId);

    view.setOnClickListener(new View.OnClickListener() {

        @Override//from  w  w  w . ja v  a2  s. c o m
        public void onClick(View v) {
            Intent intent = new Intent(context, clazz);
            if (flags > 0) {
                intent.setFlags(flags);
            }
            context.startActivity(intent);

        }
    });

}

From source file:Main.java

public static void setButtonText(Activity activity, int viewId, String text) {
    if (activity != null) {
        android.widget.Button view = (android.widget.Button) activity.findViewById(viewId);
        if (view != null && text != null)
            view.setText(text);//ww  w.j  a  va  2 s  .  c  o m
    }
}