List of utility methods to do View Get
void | changeViewState(View view, MotionEvent event) change View State if (view != null && event != null) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) { view.setPressed(true); } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { view.setPressed(false); |
ViewParent | findInParents(View view, Class> parentClass) find In Parents ViewParent par = view.getParent(); while (par != null) { if (parentClass.isAssignableFrom(par.getClass())) return par; par = par.getParent(); return null; |
T | findUsingTag(View v, int resourceId) find Using Tag Object result = v.getTag(resourceId); if (result == null) { result = (T) v.findViewById(resourceId); v.setTag(resourceId, result); return (T) result; |
int | getRandomView(int size) get Random View Random rd = new Random(); int randomInt = rd.nextInt(size); return randomInt; |
String | getname(Context mContext, View v) getname try { String name = mContext.getResources() .getResourceName(v.getId()); return name; } catch (Exception ex) { return ""; |
void | forceChildrenInvalidateRecursively(View view) force Children Invalidate Recursively if (view instanceof ViewGroup) { ViewGroup childGroup = (ViewGroup) view; int childCnt = childGroup.getChildCount(); for (int i = 0; i < childCnt; i++) { View childView = childGroup.getChildAt(i); forceChildrenInvalidateRecursively(childView); if (view != null) { view.invalidate(); |