Android examples for User Interface:ViewGroup
apply Dialog Style to ViewGroup
//package com.java2s; import android.graphics.Color; import android.os.Build; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.TextView; public class Main { public static void applyDialogStyle(ViewGroup viewGroup) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { return; }/*from ww w. ja v a 2s .co m*/ viewGroup.setBackgroundColor(Color.BLACK); // Theme.AppCompat.Light makes all text and background black final int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View childView = viewGroup.getChildAt(i); if (childView instanceof ListView) { childView.setBackgroundColor(Color.LTGRAY); } else if (childView instanceof ViewGroup) { applyDialogStyle((ViewGroup) childView); } else if (childView instanceof TextView) { ((TextView) childView).setTextColor(Color.WHITE); } } } }