public static void delete(ViewGroup target) { View view = target.findViewWithTag(TAG); if (view != null) { target.removeView(view); } }
/** * use reserved order to remove is more quickly. */ private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
@Test public void shouldNotFindViewWithTagReturnNull() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3, 1); assertThat((View) root.findViewWithTag("tag21")).isNull(); assertThat((ViewGroup) root.findViewWithTag("tag23")).isNull(); }
@Test public void shouldFindViewWithTag() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3, 1); assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); }
@Test public void shouldfindViewWithTagFromCorrectViewGroup() { root.removeAllViews(); child1.setTag("tag1"); child2.setTag("tag2"); child3.setTag("tag3"); root.addView(child1); root.addView(child2); root.addView(child3); child3a.setTag("tag1"); child3b.setTag("tag2"); //can find views by tag from root assertThat((View) root.findViewWithTag("tag1")).isSameAs(child1); assertThat((View) root.findViewWithTag("tag2")).isSameAs((View) child2); assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3); //can find views by tag from child3 assertThat((View) child3.findViewWithTag("tag1")).isSameAs(child3a); assertThat((View) child3.findViewWithTag("tag2")).isSameAs(child3b); }
private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
private static void removeFakeStatusBarViewIfExist(Activity activity) { Window window = activity.getWindow(); ViewGroup mDecorView = (ViewGroup) window.getDecorView(); View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW); if (fakeView != null) { mDecorView.removeView(fakeView); } }
private boolean isShow(Activity activity) { ViewGroup rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content); String tag = activity.getResources().getString(R.string.tag_base_custom_view); BaseKeyboardView baseKeyboardView = rootView.findViewWithTag(tag); return baseKeyboardView != null; }
@Override public Object instantiateItem(ViewGroup container, final int position) { View view = container.findViewWithTag(position); if (view == null) { view = getItemViews().get(position); view.setTag(position); container.addView(getItemViews().get(position)); } view.setVisibility(VISIBLE); return view; }
@TargetApi(Build.VERSION_CODES.KITKAT) private static void clearPreviousSetting(Activity activity) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); View fakeStatusBarView = decorView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG); if (fakeStatusBarView != null) { decorView.removeView(fakeStatusBarView); ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0); rootView.setPadding(0, 0, 0, 0); } }
private void hide(Activity activity) { ViewGroup rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content); String tag = activity.getResources().getString(R.string.tag_base_custom_view); BaseKeyboardView baseKeyboardView = rootView.findViewWithTag(tag); if (baseKeyboardView != null) { rootView.removeView(baseKeyboardView); baseKeyboardView.setVisibility(View.GONE); } }
private static void addTopView(@NonNull final Activity activity, @IntRange(from = 0, to = 255) final int alpha) { ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content); View fakeTranslucentView = contentView.findViewWithTag(FAKE_TOP_VIEW_TAG); if (fakeTranslucentView != null) { if (fakeTranslucentView.getVisibility() == View.GONE) { fakeTranslucentView.setVisibility(View.VISIBLE); } fakeTranslucentView.setBackgroundColor(Color.argb(alpha, 0, 0, 0)); } else { contentView.addView(createAlphaStatusBarView(activity, alpha)); } }
@Override public void finishUpdate(ViewGroup container) { super.finishUpdate(container); View view = container.findViewWithTag(mBannerPage.getCurrentItem()); if (view != null) { view.setEnabled(true); } }
@Override public Object instantiateItem(ViewGroup container, final int page) { EmotionGridView v = container.findViewWithTag(page); if (v == null) { final int tabpos = pageToTabPos(page); int pageStart = page - getPageCountBefore(tabpos); int index = pageStart * ROW_COUNT * COLOUM_COUNT; v = new EmotionGridView(context, smileys.get(tabpos), COLOUM_COUNT, ROW_COUNT, index, emotionInputHandler); v.setLayoutParams(new LayoutParams(LMP, LMP)); v.setTag(page); container.addView(v); } return v; }
public FlexibleLayout(Context context) { super(context); setOrientation(VERTICAL); setClipToPadding(true); setFitsSystemWindows(true); inflate(context, R.layout.layout_all, this); mSuccessView = initNormalView(); title = mSuccessView.findViewWithTag("title"); LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); addView(mSuccessView, lp); int childCount = mSuccessView.getChildCount(); Log.d("count---", String.valueOf(childCount)); }
@Override public boolean call(ViewGroup view) { boolean isDotView = view.getTag().equals("dotView"); if (!isDotView) return false; View dotViewVisitedStep = view.findViewWithTag("dotViewVisitedStep"); return dotViewVisitedStep.getScaleX() == 1; } }, nDotsMatcher, "number of dots visited");
@Override public boolean call(ViewGroup view) { boolean isSeparatorView = view.getTag().equals("separatorView"); if (!isSeparatorView) return false; View dotViewVisitedStep = view.findViewWithTag("separatorViewVisitedStep"); return dotViewVisitedStep.getScaleX() == 1; } }, nSeparatorsMatcher, "number of separators visited");