List of usage examples for android.app Activity findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:Main.java
public static void setText(Activity activity, int viewId, String text) { if (activity != null) { android.widget.TextView view = (android.widget.TextView) activity.findViewById(viewId); if (view != null) view.setText(text);/*from ww w . ja v a 2s . c om*/ } }
From source file:com.viktorrudometkin.burramys.utils.UiUtils.java
static public void showMessage(@NonNull Activity activity, @NonNull String message) { View coordinatorLayout = activity.findViewById(R.id.coordinator_layout); Snackbar snackbar = Snackbar.make(/* w w w.ja v a 2 s .com*/ (coordinatorLayout != null ? coordinatorLayout : activity.findViewById(android.R.id.content)), message, Snackbar.LENGTH_SHORT); snackbar.getView().setBackgroundResource(R.color.material_grey_900); snackbar.show(); }
From source file:tyrantgit.explosionfield.ExplosionField.java
public static ExplosionField attach2Window(Activity activity) { ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT); ExplosionField explosionField = new ExplosionField(activity); rootView.addView(explosionField, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return explosionField; }
From source file:com.lixplor.fastutil.utils.control.KeyboardUtil.java
public static void show(@NonNull Activity activity) { show(activity.findViewById(android.R.id.content)); }
From source file:com.lixplor.fastutil.utils.control.KeyboardUtil.java
public static void hide(@NonNull Activity activity) { hide(activity.findViewById(android.R.id.content)); }
From source file:Main.java
public static View findActionBarContainer(Activity activity) { if (Build.VERSION.SDK_INT > 11) { int id = activity.getResources().getIdentifier("action_bar_container", "id", "android"); return activity.findViewById(id); } else {// ww w . ja v a2s .c om return null; } }
From source file:Main.java
public static Bitmap getScaledScreenshot(final Activity activity, int scaleWidth, int scaleHeight, boolean relativeScaleIfTrue) { final View someView = activity.findViewById(android.R.id.content); final View rootView = someView.getRootView(); final boolean originalCacheState = rootView.isDrawingCacheEnabled(); rootView.setDrawingCacheEnabled(true); rootView.buildDrawingCache(true);//from w w w . j a v a 2 s . c o m // We could get a null or zero px bitmap if the rootView hasn't been measured // appropriately, or we grab it before layout. // This is ok, and we should handle it gracefully. final Bitmap original = rootView.getDrawingCache(); Bitmap scaled = null; if (null != original && original.getWidth() > 0 && original.getHeight() > 0) { if (relativeScaleIfTrue) { scaleWidth = original.getWidth() / scaleWidth; scaleHeight = original.getHeight() / scaleHeight; } if (scaleWidth > 0 && scaleHeight > 0) { try { scaled = Bitmap.createScaledBitmap(original, scaleWidth, scaleHeight, false); } catch (OutOfMemoryError error) { Log.i(LOGTAG, "Not enough memory to produce scaled image, returning a null screenshot"); } } } if (!originalCacheState) { rootView.setDrawingCacheEnabled(false); } return scaled; }
From source file:com.lixplor.fastutil.utils.control.KeyboardUtil.java
public static void removeOnKeyboardVisibilityChangedListener(@NonNull Activity activity) { View rootLayout = activity.findViewById(android.R.id.content); rootLayout.getViewTreeObserver().removeOnGlobalLayoutListener(sMyOnGlobalLayoutListener); }
From source file:org.tanrabad.survey.presenter.view.MainActivityNavigation.java
private static void setupDrawerButton(final Activity activity) { activity.findViewById(R.id.drawer_button).setOnClickListener(new View.OnClickListener() { @Override// w w w .j a va 2 s. c o m public void onClick(View view) { DrawerLayout drawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); drawerLayout.openDrawer(GravityCompat.START); } }); User user = AccountUtils.getUser(); TextView userFullNameTextView = (TextView) activity.findViewById(R.id.user_fullname); userFullNameTextView.setText(String.format("%s %s", user.getFirstname(), user.getLastname())); Organization organization = BrokerOrganizationRepository.getInstance().findById(user.getOrganizationId()); TextView organizationTextView = (TextView) activity.findViewById(R.id.organization); organizationTextView.setText(organization.getName()); }
From source file:Main.java
public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content)); contentView.setPadding(0, getStatusBarHeight(activity), 0, 0); contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); setTransparentForWindow(activity); }/*from w w w. j a v a 2 s . c om*/ }