亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Android提高十七篇之多級(jí)樹(shù)形菜單的實(shí)現(xiàn)

系統(tǒng) 2004 0

在 Android里要實(shí)現(xiàn)樹(shù)形菜單,都是用ExpandableList(也有高手自己繼承ListView或者LinearLayout來(lái)做),但是 ExpandableList一般只能實(shí)現(xiàn)2級(jí)樹(shù)形菜單......本文也依然使用ExpandableList,但是要實(shí)現(xiàn)的是3級(jí)樹(shù)形菜單。 本文程序運(yùn)行效果圖:

當(dāng) 用BaseExpandableListAdapter來(lái)實(shí)現(xiàn)二級(jí)樹(shù)形菜單時(shí),父項(xiàng)(getGroupView())和子項(xiàng) (getChildView())都是使用TextView。當(dāng)要實(shí)現(xiàn)三級(jí)樹(shù)形菜單時(shí),子項(xiàng)(getChildView())就必須使用 ExpandableList了.......另外還要定義結(jié)構(gòu)體來(lái)方便調(diào)用三級(jí)樹(shù)形的數(shù)據(jù), 二級(jí)樹(shù)形菜單可以用如下:

view plaincopy to clipboardprint?
  1. static ? public ? class ?TreeNode{??
  2. ????Object?parent;??
  3. ????List<Object>?childs= new ?ArrayList<Object>();??
  4. }??

三級(jí)樹(shù)形菜單可以用如下,子項(xiàng)是二級(jí)樹(shù)形菜單的結(jié)構(gòu)體:

view plaincopy to clipboardprint?
  1. static ? public ? class ?SuperTreeNode?{??
  2. ????Object?parent;??
  3. ???? //二級(jí)樹(shù)形菜單的結(jié)構(gòu)體 ??
  4. ????List<TreeViewAdapter.TreeNode>?childs?=? new ?ArrayList<TreeViewAdapter.TreeNode>();??
  5. }??

實(shí)現(xiàn)三級(jí)樹(shù)形菜單有兩點(diǎn)要注意的:

1、第二級(jí)也是個(gè)樹(shù)形菜單,因此必須在第二級(jí)項(xiàng)目展開(kāi)/回收時(shí)設(shè)置足夠的空間來(lái)完全顯示二級(jí)樹(shù)形菜單;

2、在實(shí)現(xiàn)三級(jí)樹(shù)形菜單時(shí),發(fā)現(xiàn)菜單的方法都是用不了(如OnChildClickListener、OnGroupClickListener等),因此要獲得選中的數(shù)據(jù)就必須在外部定義好回調(diào)函數(shù),然后在第二級(jí)生成二級(jí)樹(shù)形菜單時(shí)回調(diào)這個(gè)外部函數(shù)。

PS:本文在解決No.2關(guān)鍵點(diǎn)的時(shí)候,只能取得第三級(jí)選中的序號(hào).....而第一,第二級(jí)依然無(wú)法獲取其序號(hào)。

main.xml源碼如下:

view plaincopy to clipboardprint?
  1. <? xml ? version = "1.0" ? encoding = "utf-8" ?> ??
  2. < LinearLayout ? xmlns:android = "http://schemas.android.com/apk/res/android" ??
  3. ???? android:orientation = "vertical" ? android:layout_width = "fill_parent" ??
  4. ???? android:layout_height = "fill_parent" > ??
  5. ???? < LinearLayout ? android:id = "@+id/LinearLayout01" ??
  6. ???????? android:layout_width = "wrap_content" ? android:layout_height = "wrap_content" > ??
  7. ???????? < Button ? android:layout_height = "wrap_content" ? android:text = "兩層結(jié)構(gòu)" ??
  8. ???????????? android:layout_width = "160dip" ? android:id = "@+id/btnNormal" > </ Button > ??
  9. ???????? < Button ? android:layout_height = "wrap_content" ? android:text = "三層結(jié)構(gòu)" ??
  10. ???????????? android:layout_width = "160dip" ? android:id = "@+id/btnSuper" > </ Button > ??
  11. ???? </ LinearLayout > ??
  12. ???? < ExpandableListView ? android:id = "@+id/ExpandableListView01" ??
  13. ???????? android:layout_width = "fill_parent" ? android:layout_height = "fill_parent" > </ ExpandableListView > ??
  14. </ LinearLayout > ??

testExpandableList.java是主類,調(diào)用其他工具類,源碼如下:

view plaincopy to clipboardprint?
  1. package ?com.testExpandableList;??
  2. ??
  3. ??
  4. import ?java.util.List;??
  5. import ?android.app.Activity;??
  6. import ?android.os.Bundle;??
  7. import ?android.util.Log;??
  8. import ?android.view.View;??
  9. import ?android.widget.Button;??
  10. import ?android.widget.ExpandableListView;??
  11. import ?android.widget.ExpandableListView.OnChildClickListener;??
  12. import ?android.widget.Toast;??
  13. ??
  14. public ? class ?testExpandableList? extends ?Activity?{??
  15. ???? /**?Called?when?the?activity?is?first?created.?*/ ??
  16. ????ExpandableListView?expandableList;??
  17. ????TreeViewAdapter?adapter;??
  18. ????SuperTreeViewAdapter?superAdapter;??
  19. ????Button?btnNormal,btnSuper;??
  20. ???? //?Sample?data?set.??children[i]?contains?the?children?(String[])?for?groups[i]. ??
  21. ???? public ?String[]?groups?=?{? "xxxx好友" ,? "xxxx同學(xué)" ,? "xxxxx女人" };??
  22. ???? public ?String[][]??child=?{??
  23. ????????????{? "A君" ,? "B君" ,? "C君" ,? "D君" ?},??
  24. ????????????{? "同學(xué)甲" ,? "同學(xué)乙" ,? "同學(xué)丙" },??
  25. ????????????{? "御姐" ,? "蘿莉" ?}??
  26. ????};??
  27. ??????
  28. ???? public ?String[]?parent?=?{? "xxxx好友" ,? "xxxx同學(xué)" };??
  29. ???? public ?String[][][]??child_grandson=?{??
  30. ????????????{{ "A君" },??
  31. ????????????????{ "AA" , "AAA" }},??
  32. ????????????{{ "B君" },??
  33. ????????????????{ "BBB" , "BBBB" , "BBBBB" }},??
  34. ????????????{{ "C君" },??
  35. ????????????????{ "CCC" , "CCCC" }},??
  36. ????????????{{ "D君" },??
  37. ????????????????{ "DDD" , "DDDD" , "DDDDD" }},??
  38. ????};??
  39. ??????
  40. ???? @Override ??
  41. ???? public ? void ?onCreate(Bundle?savedInstanceState)?{??
  42. ???????? super .onCreate(savedInstanceState);??
  43. ????????setContentView(R.layout.main);??
  44. ???????? this .setTitle( "ExpandableListView練習(xí)----hellogv" );??
  45. ????????btnNormal=(Button) this .findViewById(R.id.btnNormal);??
  46. ????????btnNormal.setOnClickListener( new ?ClickEvent());??
  47. ????????btnSuper=(Button) this .findViewById(R.id.btnSuper);??
  48. ????????btnSuper.setOnClickListener( new ?ClickEvent());??
  49. ????????adapter= new ?TreeViewAdapter( this ,TreeViewAdapter.PaddingLeft>> 1 );??
  50. ????????superAdapter= new ?SuperTreeViewAdapter( this ,stvClickEvent);??
  51. ????????expandableList=(ExpandableListView)?testExpandableList. this .findViewById(R.id.ExpandableListView01);??
  52. ????}??
  53. ??????
  54. ???? class ?ClickEvent? implements ?View.OnClickListener{??
  55. ??
  56. ???????? @Override ??
  57. ???????? public ? void ?onClick(View?v)?{??
  58. ????????????adapter.RemoveAll();??
  59. ????????????adapter.notifyDataSetChanged();??
  60. ????????????superAdapter.RemoveAll();??
  61. ????????????superAdapter.notifyDataSetChanged();??
  62. ??????????????
  63. ???????????? if (v==btnNormal)??
  64. ????????????{??
  65. ????????????????List<TreeViewAdapter.TreeNode>?treeNode?=?adapter.GetTreeNode();??
  66. ???????????????? for ( int ?i= 0 ;i<groups.length;i++)??
  67. ????????????????{??
  68. ????????????????????TreeViewAdapter.TreeNode?node= new ?TreeViewAdapter.TreeNode();??
  69. ????????????????????node.parent=groups[i];??
  70. ???????????????????? for ( int ?ii= 0 ;ii<child[i].length;ii++)??
  71. ????????????????????{??
  72. ????????????????????????node.childs.add(child[i][ii]);??
  73. ????????????????????}??
  74. ????????????????????treeNode.add(node);??
  75. ????????????????}??
  76. ??????????????????
  77. ????????????????adapter.UpdateTreeNode(treeNode);???????
  78. ????????????????expandableList.setAdapter(adapter);??
  79. ????????????????expandableList.setOnChildClickListener( new ?OnChildClickListener(){??
  80. ??
  81. ???????????????????? @Override ??
  82. ???????????????????? public ? boolean ?onChildClick(ExpandableListView?arg0,?View?arg1,??
  83. ???????????????????????????? int ?parent,? int ?children,? long ?arg4)?{??
  84. ??????????????????????????
  85. ????????????????????????String?str= "parent?id:" +String.valueOf(parent)+ ",children?id:" +String.valueOf(children);??
  86. ????????????????????????Toast.makeText(testExpandableList. this ,?str,? 300 ).show();??
  87. ???????????????????????? return ? false ;??
  88. ????????????????????}??
  89. ????????????????});??
  90. ????????????}??
  91. ???????????? else ? if (v==btnSuper){??
  92. ????????????????List<SuperTreeViewAdapter.SuperTreeNode>?superTreeNode?=?superAdapter.GetTreeNode();??
  93. ???????????????? for ( int ?i= 0 ;i<parent.length;i++) //第一層 ??
  94. ????????????????{??
  95. ????????????????????SuperTreeViewAdapter.SuperTreeNode?superNode= new ?SuperTreeViewAdapter.SuperTreeNode();??
  96. ????????????????????superNode.parent=parent[i];??
  97. ??????????????????????
  98. ???????????????????? //第二層 ??
  99. ???????????????????? for ( int ?ii= 0 ;ii<child_grandson.length;ii++)??
  100. ????????????????????{??
  101. ????????????????????????TreeViewAdapter.TreeNode?node= new ?TreeViewAdapter.TreeNode();??
  102. ????????????????????????node.parent=child_grandson[ii][ 0 ][ 0 ]; //第二級(jí)菜單的標(biāo)題 ??
  103. ??????????????????????????
  104. ???????????????????????? for ( int ?iii= 0 ;iii<child_grandson[ii][ 1 ].length;iii++) //第三級(jí)菜單 ??
  105. ????????????????????????{??
  106. ????????????????????????????node.childs.add(child_grandson[ii][ 1 ][iii]);??
  107. ????????????????????????}??
  108. ????????????????????????superNode.childs.add(node);??
  109. ????????????????????}??
  110. ????????????????????superTreeNode.add(superNode);??
  111. ??????????????????????
  112. ????????????????}??
  113. ????????????????superAdapter.UpdateTreeNode(superTreeNode);??
  114. ????????????????expandableList.setAdapter(superAdapter);??
  115. ????????????}??
  116. ????????}??
  117. ????}??
  118. ??
  119. ???? /** ?
  120. ?????*?三級(jí)樹(shù)形菜單的事件不再可用,本函數(shù)由三級(jí)樹(shù)形菜單的子項(xiàng)(二級(jí)菜單)進(jìn)行回調(diào) ?
  121. ?????*/ ??
  122. ????OnChildClickListener?stvClickEvent= new ?OnChildClickListener(){??
  123. ??
  124. ???????? @Override ??
  125. ???????? public ? boolean ?onChildClick(ExpandableListView?parent,??
  126. ????????????????View?v,? int ?groupPosition,? int ?childPosition,??
  127. ???????????????? long ?id)?{??
  128. ????????????String?str= "parent?id:" +String.valueOf(groupPosition)+ ",children?id:" +String.valueOf(childPosition);??
  129. ????????????Toast.makeText(testExpandableList. this ,?str,? 300 ).show();??
  130. ??????????????
  131. ???????????? return ? false ;??
  132. ????????}??
  133. ??????????
  134. ????};??
  135. }??

TreeViewAdapter.java是實(shí)現(xiàn)二級(jí)樹(shù)形菜單的工具類,源碼如下:

view plaincopy to clipboardprint?
  1. package ?com.testExpandableList;??
  2. ??
  3. import ?java.util.ArrayList;??
  4. import ?java.util.List;??
  5. import ?android.content.Context;??
  6. import ?android.util.Log;??
  7. import ?android.view.Gravity;??
  8. import ?android.view.View;??
  9. import ?android.view.ViewGroup;??
  10. import ?android.widget.AbsListView;??
  11. import ?android.widget.BaseExpandableListAdapter;??
  12. import ?android.widget.TextView;??
  13. ??
  14. ??
  15. public ? class ?TreeViewAdapter? extends ?BaseExpandableListAdapter{??
  16. ???? public ? static ? final ? int ?ItemHeight= 48 ; //每項(xiàng)的高度 ??
  17. ???? public ? static ? final ? int ?PaddingLeft= 36 ; //每項(xiàng)的高度 ??
  18. ???? private ? int ?myPaddingLeft= 0 ; //如果是由SuperTreeView調(diào)用,則作為子項(xiàng)需要往右移 ??
  19. ??
  20. ???? static ? public ? class ?TreeNode{??
  21. ????????Object?parent;??
  22. ????????List<Object>?childs= new ?ArrayList<Object>();??
  23. ????}??
  24. ??????
  25. ????List<TreeNode>?treeNodes?=? new ?ArrayList<TreeNode>();??
  26. ????Context?parentContext;??
  27. ??????
  28. ???? public ?TreeViewAdapter(Context?view, int ?myPaddingLeft)??
  29. ????{??
  30. ????????parentContext=view;??
  31. ???????? this .myPaddingLeft=myPaddingLeft;??
  32. ????}??
  33. ??????
  34. ???? public ?List<TreeNode>?GetTreeNode()??
  35. ????{??
  36. ???????? return ?treeNodes;??
  37. ????}??
  38. ??????
  39. ???? public ? void ?UpdateTreeNode(List<TreeNode>?nodes)??
  40. ????{??
  41. ????????treeNodes=nodes;??
  42. ????}??
  43. ??????
  44. ???? public ? void ?RemoveAll()??
  45. ????{??
  46. ????????treeNodes.clear();??
  47. ????}??
  48. ??????
  49. ???? public ?Object?getChild( int ?groupPosition,? int ?childPosition)?{??
  50. ???????? return ?treeNodes.get(groupPosition).childs.get(childPosition);??
  51. ????}??
  52. ??
  53. ???? public ? int ?getChildrenCount( int ?groupPosition)?{??
  54. ???????? return ?treeNodes.get(groupPosition).childs.size();??
  55. ????}??
  56. ??
  57. ???? static ? public ?TextView?getTextView(Context?context)?{??
  58. ????????AbsListView.LayoutParams?lp?=? new ?AbsListView.LayoutParams(??
  59. ????????????????ViewGroup.LayoutParams.FILL_PARENT,?ItemHeight);??
  60. ??
  61. ????????TextView?textView?=? new ?TextView(context);??
  62. ????????textView.setLayoutParams(lp);??
  63. ????????textView.setGravity(Gravity.CENTER_VERTICAL?|?Gravity.LEFT);??
  64. ???????? return ?textView;??
  65. ????}??
  66. ??
  67. ???? public ?View?getChildView( int ?groupPosition,? int ?childPosition,??
  68. ???????????? boolean ?isLastChild,?View?convertView,?ViewGroup?parent)?{??
  69. ????????TextView?textView?=?getTextView( this .parentContext);??
  70. ????????textView.setText(getChild(groupPosition,?childPosition).toString());??
  71. ????????textView.setPadding(myPaddingLeft+PaddingLeft,? 0 ,? 0 ,? 0 );??
  72. ???????? return ?textView;??
  73. ????}??
  74. ??
  75. ???? public ?View?getGroupView( int ?groupPosition,? boolean ?isExpanded,??
  76. ????????????View?convertView,?ViewGroup?parent)?{??
  77. ????????TextView?textView?=?getTextView( this .parentContext);??
  78. ????????textView.setText(getGroup(groupPosition).toString());??
  79. ????????textView.setPadding(myPaddingLeft+(PaddingLeft>> 1 ),? 0 ,? 0 ,? 0 );??
  80. ???????? return ?textView;??
  81. ????}??
  82. ??
  83. ???? public ? long ?getChildId( int ?groupPosition,? int ?childPosition)?{??
  84. ???????? return ?childPosition;??
  85. ????}??
  86. ??
  87. ???? public ?Object?getGroup( int ?groupPosition)?{??
  88. ???????? return ?treeNodes.get(groupPosition).parent;??
  89. ????}??
  90. ??
  91. ???? public ? int ?getGroupCount()?{??
  92. ???????? return ?treeNodes.size();??
  93. ????}??
  94. ??
  95. ???? public ? long ?getGroupId( int ?groupPosition)?{??
  96. ???????? return ?groupPosition;??
  97. ????}??
  98. ??
  99. ???? public ? boolean ?isChildSelectable( int ?groupPosition,? int ?childPosition)?{??
  100. ???????? return ? true ;??
  101. ????}??
  102. ??
  103. ???? public ? boolean ?hasStableIds()?{??
  104. ???????? return ? true ;??
  105. ????}??
  106. }??

SuperTreeViewAdapter.java是實(shí)現(xiàn)三級(jí)樹(shù)形菜單的工具類,會(huì)用到 TreeViewAdapter.java ,源碼如下:

view plaincopy to clipboardprint?
  1. package ?com.testExpandableList;??
  2. ??
  3. import ?java.util.ArrayList;??
  4. import ?java.util.List;??
  5. import ?com.testExpandableList.TreeViewAdapter.TreeNode;??
  6. import ?android.content.Context;??
  7. import ?android.view.View;??
  8. import ?android.view.ViewGroup;??
  9. import ?android.widget.AbsListView;??
  10. import ?android.widget.BaseExpandableListAdapter;??
  11. import ?android.widget.ExpandableListView;??
  12. import ?android.widget.ExpandableListView.OnChildClickListener;??
  13. import ?android.widget.ExpandableListView.OnGroupCollapseListener;??
  14. import ?android.widget.ExpandableListView.OnGroupExpandListener;??
  15. import ?android.widget.TextView;??
  16. ??
  17. public ? class ?SuperTreeViewAdapter? extends ?BaseExpandableListAdapter?{??
  18. ??
  19. ???? static ? public ? class ?SuperTreeNode?{??
  20. ????????Object?parent;??
  21. ???????? //二級(jí)樹(shù)形菜單的結(jié)構(gòu)體 ??
  22. ????????List<TreeViewAdapter.TreeNode>?childs?=? new ?ArrayList<TreeViewAdapter.TreeNode>();??
  23. ????}??
  24. ??
  25. ???? private ?List<SuperTreeNode>?superTreeNodes?=? new ?ArrayList<SuperTreeNode>();??
  26. ???? private ?Context?parentContext;??
  27. ???? private ?OnChildClickListener?stvClickEvent; //外部回調(diào)函數(shù) ??
  28. ??????
  29. ???? public ?SuperTreeViewAdapter(Context?view,OnChildClickListener?stvClickEvent)?{??
  30. ????????parentContext?=?view;??
  31. ???????? this .stvClickEvent=stvClickEvent;??
  32. ????}??
  33. ??
  34. ???? public ?List<SuperTreeNode>?GetTreeNode()?{??
  35. ???????? return ?superTreeNodes;??
  36. ????}??
  37. ??
  38. ???? public ? void ?UpdateTreeNode(List<SuperTreeNode>?node)?{??
  39. ????????superTreeNodes?=?node;??
  40. ????}??
  41. ??????
  42. ???? public ? void ?RemoveAll()??
  43. ????{??
  44. ????????superTreeNodes.clear();??
  45. ????}??
  46. ??????
  47. ???? public ?Object?getChild( int ?groupPosition,? int ?childPosition)?{??
  48. ???????? return ?superTreeNodes.get(groupPosition).childs.get(childPosition);??
  49. ????}??
  50. ??
  51. ???? public ? int ?getChildrenCount( int ?groupPosition)?{??
  52. ???????? return ?superTreeNodes.get(groupPosition).childs.size();??
  53. ????}??
  54. ??
  55. ???? public ?ExpandableListView?getExpandableListView()?{??
  56. ????????AbsListView.LayoutParams?lp?=? new ?AbsListView.LayoutParams(??
  57. ????????????????ViewGroup.LayoutParams.FILL_PARENT,?TreeViewAdapter.ItemHeight);??
  58. ????????ExpandableListView?superTreeView?=? new ?ExpandableListView(parentContext);??
  59. ????????superTreeView.setLayoutParams(lp);??
  60. ???????? return ?superTreeView;??
  61. ????}??
  62. ??
  63. ???? /** ?
  64. ?????*?三層樹(shù)結(jié)構(gòu)中的第二層是一個(gè)ExpandableListView ?
  65. ?????*/ ???
  66. ???? public ?View?getChildView( int ?groupPosition,? int ?childPosition,??
  67. ???????????? boolean ?isLastChild,?View?convertView,?ViewGroup?parent)?{??
  68. ???????? //?是? ??
  69. ???????? final ?ExpandableListView?treeView?=?getExpandableListView();??
  70. ???????? final ?TreeViewAdapter?treeViewAdapter?=? new ?TreeViewAdapter( this .parentContext, 0 );??
  71. ????????List<TreeNode>?tmp?=?treeViewAdapter.GetTreeNode(); //臨時(shí)變量取得TreeViewAdapter的TreeNode集合,可為空 ??
  72. ???????? final ?TreeNode?treeNode=(TreeNode)?getChild(groupPosition,?childPosition);??
  73. ????????tmp.add(treeNode);??
  74. ????????treeViewAdapter.UpdateTreeNode(tmp);??
  75. ????????treeView.setAdapter(treeViewAdapter);??
  76. ??????????
  77. ???????? //關(guān)鍵點(diǎn):取得選中的二級(jí)樹(shù)形菜單的父子節(jié)點(diǎn),結(jié)果返回給外部回調(diào)函數(shù) ??
  78. ????????treeView.setOnChildClickListener( this .stvClickEvent);??
  79. ??????????
  80. ???????? /** ?
  81. ?????????*?關(guān)鍵點(diǎn):第二級(jí)菜單展開(kāi)時(shí)通過(guò)取得節(jié)點(diǎn)數(shù)來(lái)設(shè)置第三級(jí)菜單的大小 ?
  82. ?????????*/ ??
  83. ????????treeView.setOnGroupExpandListener( new ?OnGroupExpandListener()?{??
  84. ???????????? @Override ??
  85. ???????????? public ? void ?onGroupExpand( int ?groupPosition)?{??
  86. ??????????????????
  87. ????????????????AbsListView.LayoutParams?lp?=? new ?AbsListView.LayoutParams(??
  88. ????????????????????????ViewGroup.LayoutParams.FILL_PARENT,??
  89. ????????????????????????(treeNode.childs.size()+ 1 )*TreeViewAdapter.ItemHeight?+? 10 );??
  90. ????????????????treeView.setLayoutParams(lp);??
  91. ????????????}??
  92. ????????});??
  93. ??????????
  94. ???????? /** ?
  95. ?????????*?第二級(jí)菜單回收時(shí)設(shè)置為標(biāo)準(zhǔn)Item大小 ?
  96. ?????????*/ ??
  97. ????????treeView.setOnGroupCollapseListener( new ?OnGroupCollapseListener()?{??
  98. ???????????? @Override ??
  99. ???????????? public ? void ?onGroupCollapse( int ?groupPosition)?{??
  100. ??????????????????
  101. ????????????????AbsListView.LayoutParams?lp?=? new ?AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,??
  102. ????????????????????????TreeViewAdapter.ItemHeight);??
  103. ????????????????treeView.setLayoutParams(lp);??
  104. ????????????}??
  105. ????????});??
  106. ????????treeView.setPadding(TreeViewAdapter.PaddingLeft,? 0 ,? 0 ,? 0 );??
  107. ???????? return ?treeView;??
  108. ????}??
  109. ??
  110. ???? /** ?
  111. ?????*?三級(jí)樹(shù)結(jié)構(gòu)中的首層是TextView,用于作為title ?
  112. ?????*/ ??
  113. ???? public ?View?getGroupView( int ?groupPosition,? boolean ?isExpanded,??
  114. ????????????View?convertView,?ViewGroup?parent)?{??
  115. ????????TextView?textView?=?TreeViewAdapter.getTextView( this .parentContext);??
  116. ????????textView.setText(getGroup(groupPosition).toString());??
  117. ????????textView.setPadding(TreeViewAdapter.PaddingLeft,? 0 ,? 0 ,? 0 );??
  118. ???????? return ?textView;??
  119. ????}??
  120. ??
  121. ???? public ? long ?getChildId( int ?groupPosition,? int ?childPosition)?{??
  122. ???????? return ?childPosition;??
  123. ????}??
  124. ??
  125. ???? public ?Object?getGroup( int ?groupPosition)?{??
  126. ???????? return ?superTreeNodes.get(groupPosition).parent;??
  127. ????}??
  128. ??
0
0
分享到:
評(píng)論

Android提高十七篇之多級(jí)樹(shù)形菜單的實(shí)現(xiàn)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 久久国产精品无码网站 | 99热国产这里只有精品免费 | 亚洲视频播放 | 96精品视频在线播放免费观看 | 亚洲狠狠色丁香婷婷综合 | 日日操日日 | 天堂一区二区三区精品 | 天天操天天射天天舔 | 国产成+人欧美+综合在线观看 | 日本一级毛片中文字幕 | 亚洲天天做夜夜做天天欢人人 | 精品国产免费第一区二区三区日韩 | 97 在线播放 | 2019亚洲日韩新视频 | 台湾一级毛片永久免费 | 久久久噜噜噜久噜久久 | 亚洲成综合 | 亚洲国产免费 | 日本免费不卡一区 | 亚洲欧美日韩精品香蕉 | 五月天婷婷视频 | 亚洲精品视频久久 | 俄罗斯毛片免费大全 | 国产欧美综合一区二区 | 激情影院费观看 | 天天久久综合 | 一级毛片短视频 | 久久精品麻豆 | 亚洲精品久久国产小说 | 亚洲精品一二三区 | 2021久久伊人精品中文字幕有 | 中文字幕日韩精品亚洲七区 | 国产乱码精品一区二区三区卡 | 一级理论片 | 成年女人在线观看片免费视频 | 欧美黄页网 | 中文字幕视频一区二区 | 交换国产精品视频一区 | 一本岛高清v不卡免费一三区 | 精品成人免费一区二区在线播放 | 日本美女视频韩国视频网站免费 |