view group
来源:互联网 发布:apk软件开发工具 编辑:程序博客网 时间:2024/05/02 15:49
get view group, need to be improved.
public class HelloworldActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); FrameLayout decor = (FrameLayout)getWindow().getDecorView(); dumpViewGroup(decor); } LinkedList <View> gViewQueue = new LinkedList<View>(); int gLevel = 0; public void dumpViewGroup(ViewGroup vg) { final int count = vg.getChildCount(); //Log.d(TAG, "lyftest count="+count); for (int i = 0; i < count; i++) { final View child = vg.getChildAt(i); //if (child instanceof ViewGroup) showViewName(child,gLevel); gViewQueue.add(child); } gLevel++; showlevelmark(gLevel); while(!gViewQueue.isEmpty()) { View headview= gViewQueue.remove(); if(headview instanceof ViewGroup) { dumpViewGroup((ViewGroup)headview); } } } public void showlevelmark(int level) { } public void showViewName(View v, int level) { Log.d("TAG", " :"+level+":view="+v+"(parent:"+v.getParent()+")"); }}
result:
09-03 16:16:23.906: DEBUG/TAG(893): :0:view=android.widget.LinearLayout@40517d70(parent:com.android.internal.policy.impl.PhoneWindow$DecorView@40517530)
09-03 16:16:23.906: DEBUG/TAG(893): :1:view=android.widget.FrameLayout@40518770(parent:android.widget.LinearLayout@40517d70)
09-03 16:16:23.906: DEBUG/TAG(893): :1:view=android.widget.FrameLayout@40519af8(parent:android.widget.LinearLayout@40517d70)
09-03 16:16:23.906: DEBUG/TAG(893): :2:view=android.widget.TextView@40518d60(parent:android.widget.FrameLayout@40518770)
09-03 16:16:23.906: DEBUG/TAG(893): :3:view=android.widget.LinearLayout@40519fc8(parent:android.widget.FrameLayout@40519af8)
09-03 16:16:23.906: DEBUG/TAG(893): :4:view=android.widget.TextView@4051a230(parent:android.widget.LinearLayout@40519fc8)
package elfylin.helloworld; import java.util.Queue; import java.util.LinkedList; import android.util.Log; import android.view.View; import android.view.ViewGroup; public class DumpViewGroup { static class ViewElement{public ViewElement(View view, int l){v = view;level = l;}View v;int level;} //static LinkedList <View> gViewQueue = new LinkedList<View>(); //static int gLevel = 0; static public void DumpViewGroup(){} static public void LevelDump(View vg, int level) { Queue viewQueue= new LinkedList<ViewElement>(); //ViewElement element = new ViewElement(vg, level); viewQueue.add(new ViewElement(vg,level)); while (!viewQueue.isEmpty()) { ViewElement head = (ViewElement) viewQueue.remove(); showViewName(head.v,head.level); if (head.v instanceof ViewGroup) { //level = level+1; for (int i = 0; i < ((ViewGroup)(head.v)).getChildCount(); i++) { final View child = ((ViewGroup)(head.v)).getChildAt(i); //if (child instanceof ViewGroup) //showViewName(child, level); viewQueue.add(new ViewElement(child,head.level+1)); } } } } static public void DepthDump(View vg, int level) { showViewName(vg, level); if (vg instanceof ViewGroup) { for (int i =0; i< ((ViewGroup)vg).getChildCount();i++) { View child = ((ViewGroup)vg).getChildAt(i); DepthDump(child,level+1); } } } public static void showlevelmark(int level) { } public static void showViewName(View v, int level) { Log.d("TAG", "lyftest :"+level+":"+(v.findFocus()!=null)+":"+(v.getVisibility())+":"+v+"( parent:"+v.getParent()+")"); } }
- view group
- 自定义view group
- 自定义view group 1
- 2G03-view-radio-group
- view group adapter的封装
- developer group answer for ViewRoot & View
- 2H03-view-radio-group-rating-bar
- How to change the ClearCase view's owner and group
- group
- group
- Group
- Group
- $group
- [转]SharePoint: Group By on more than 2 columns in a view (SP 2010)
- Yii之从User-Group-Role例子理解Model-View-Controller
- Android SQL CREATE VIEW、GROUP BY、LEFT/RIGHT OUTER JOIN、CREATE INDEX 语句
- SharePoint 2013 IT Professional——View Setting之Group By
- internet explorer cannot display image picture from google group?我的问题就这么解决了View > Encoding >
- 转 十三种设计模式的思维导图
- 一个关于Java Thread wait(),notify()的实用例
- 插入排序算法
- linux 内存管理图示
- java中的排序算法——归并排序
- view group
- linux 好书在线版(索引贴)
- 使用vector::reserve来避免不必要的重新分配
- vector的reserve和resize
- 用动态数组模拟双向循环链表
- 集合框架源码分析一(接口篇)
- 初始化首选项的方式[总结]
- 今天是我的生日,十年如一日
- C#操作Excel