List of usage examples for android.view View findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:Main.java
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null;//www. jav a2 s .c o m if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @SuppressWarnings("unchecked") public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { View decor = activity.getWindow().getDecorView(); View statusBar = null;/*from ww w.j ava2s.co m*/ if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:Main.java
/** * Create the transition participants required during a activity transition while * avoiding glitches with the system UI. * * @param activity The activity used as start for the transition. * @param includeStatusBar If false, the status bar will not be added as the transition * participant.//from ww w. j a va 2s. co m * @return All transition participants. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:Main.java
public static <E extends View> E findViewById(View view, @IdRes int resId) { if (null == view) throw new IllegalArgumentException("The argument view can not be null,please check your argument!"); //noinspection unchecked return (E) view.findViewById(resId); }
From source file:Main.java
public static View getActionBarView(Activity activity) { Window window = activity.getWindow(); View v = window.getDecorView(); // int resId = activity.getResources().getIdentifier("action_bar_container", "id", "android"); int resId = activity.getResources().getIdentifier("action_bar_container", "id", activity.getPackageName()); return v.findViewById(resId); }
From source file:Main.java
public static void setHeight(final View root, final int viewId, final int height) { if (root != null) { setHeight(root.findViewById(viewId), height); }/*w ww . ja va 2s . c o m*/ }
From source file:Main.java
public static void toastShow(String paramString, Context paramContext) { View localView = LayoutInflater.from(paramContext).inflate(getLayoutId(paramContext, "xdw_toast_item"), null);//www . ja v a 2 s. c o m Toast localToast = new Toast(paramContext); localToast.setView(localView); localToast.setGravity(17, 0, 0); ((TextView) localView.findViewById(getResId(paramContext, "xdw_toast_mes"))).setText(paramString); localToast.show(); }
From source file:com.monmonja.library.utils.ViewUtils.java
public static void makeToast(Context context, int resId) { TypedValue tv = new TypedValue(); int offsetY = 0; if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { offsetY = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); }//from w ww. j a va 2 s . c om Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); View view = toast.getView(); view.setBackgroundColor(context.getResources().getColor(R.color.toast_background)); TextView text = (TextView) view.findViewById(android.R.id.message); text.setTextColor(context.getResources().getColor(android.R.color.white)); toast.show(); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T extends View> T getViewByHolder(View view, int id) { SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); if (viewHolder == null) { viewHolder = new SparseArray<View>(); view.setTag(viewHolder);//from w w w . j av a2 s. c o m } View childView = viewHolder.get(id); if (childView == null) { childView = view.findViewById(id); viewHolder.put(id, childView); } return (T) childView; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T extends View> T get(View view, int id) { SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); if (viewHolder == null) { viewHolder = new SparseArray<View>(); view.setTag(viewHolder);//w w w .ja v a 2 s. c o m } View childView = viewHolder.get(id); if (childView == null) { childView = view.findViewById(id); viewHolder.put(id, childView); } return (T) childView; }