问题描述
我有一个包含多个组一个expandablelist,其每一个包含单个子这与多组其中每一个还含有包含另一个expandablelist单个子的expandablelist ............ ......等下水平。
03-17 23:37:30.508 1751年至1751年/ com.multilevellist E / AndroidRuntime:致命异常:主要
工艺:com.multilevellist,PID:1751
java.lang.ClassCastException:android.widget.RelativeLayout $的LayoutParams
不能转换为android.widget.AbsListView $的LayoutParams
在android.widget.ListView.setupChild(ListView.java:1826)
在android.widget.ListView.makeAndAddView(ListView.java:1793)
在android.widget.ListView.fillDown(ListView.java:691)
在android.widget.ListView.fillSpecific(ListView.java:1349)
在android.widget.ListView.layoutChildren(ListView.java:1608)
在android.widget.AbsListView.onLayout(AbsListView.java:2091)
在android.view.View.layout(View.java:14817)
在android.view.ViewGroup.layout(ViewGroup.java:4631)
在android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
在android.view.View.layout(View.java:14817)
在android.view.ViewGroup.layout(ViewGroup.java:4631)
在android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
在android.widget.FrameLayout.onLayout(FrameLayout.java:388)
在android.view.View.layout(View.java:14817)
在android.view.ViewGroup.layout(ViewGroup.java:4631)
在com.android.internal.widget.ActionBarOverlayLayout.onLayout(
ActionBarOverlayLayout.java:374)
在android.view.View.layout(View.java:14817)
在android.view.ViewGroup.layout(ViewGroup.java:4631)
在android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
在android.widget.FrameLayout.onLayout(FrameLayout.java:388)
在android.view.View.layout(View.java:14817)
在android.view.ViewGroup.layout(ViewGroup.java:4631)
在android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:5670)
在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:761)
在android.view.Choreographer.doCallbacks(Choreographer.java:574)
在android.view.Choreographer.doFrame(Choreographer.java:544)
在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:747)
在android.os.Handler.handleCallback(Handler.java:733)
在android.os.Handler.dispatchMessage(Handler.java:95)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5017)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:779)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
在dalvik.system.NativeStart.main(本机方法)
activity_main.xml中
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
工具:上下文=com.multilevellist.MainActivity>
< ExpandableListView
机器人:ID =@ + ID / TopLevelList
机器人:layout_width =match_parent
机器人:layout_height =FILL_PARENT
机器人:背景=#caa551
机器人:choiceMode =singleChoice
机器人:groupIndicator =@空
机器人:滚动条=垂直>< / ExpandableListView> < com.multilevellist.MainActivity.NextLevelListView
机器人:ID =@ + ID / NextLevelList
机器人:layout_width =match_parent
机器人:layout_height =FILL_PARENT
机器人:背景=#41ca7e
机器人:choiceMode =singleChoice
机器人:groupIndicator =@空
机器人:滚动条=垂直>< /com.multilevellist.MainActivity.NextLevelListView>
< / RelativeLayout的>
all_levels_text.xml
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
工具:上下文=com.newShop.MainActivity
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直
机器人:填充=0dp
机器人:ID =@ + ID / all_levels_text><的TextView
机器人:ID =@ + ID / TextItem
机器人:文字颜色=#000000
机器人:TEXTSIZE =15sp
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< / TextView的>< / LinearLayout中>
MainActivity.java
包com.multilevellist;进口android.app.Activity;
进口android.content.Context;
进口android.graphics.Color;
进口android.os.Bundle;
进口android.util.AttributeSet;
进口android.util.Log;
进口android.view.LayoutInflater;
进口android.view.View;
进口android.view.View.OnClickListener;
进口android.view.ViewGroup;
进口android.widget.BaseExpandableListAdapter;
进口android.widget.ExpandableListView;
进口android.widget.ExpandableListView.OnGroupExpandListener;
进口android.widget.TextView;进口的java.util.ArrayList;引入静态android.util.Log *。
公共类MainActivity延伸活动{
私人最终的ArrayList<整数GT; groupsForEachLevel =新的ArrayList<整数GT;();
私有静态最后的ArrayList<整数GT; minimumHeights =新的ArrayList<整数GT;();
私人最终的ArrayList<对象> allLevelViews =新的ArrayList<对象>(); 公共类ExpandChecker实现OnGroupExpandListener {
私人ExpandableListView的ListView;
私人诠释水平; 公共ExpandChecker(ExpandableListView的ListView,诠释级){
W(*****,onGroupExpand构造的水平+级);
this.listView = ListView的;
this.level =水平;
} @覆盖
公共无效onGroupExpand(INT groupPosition){
W(*****,onGroupExpand+水平++ minimumHeights.toString()); 的for(int i = 0; I< groupsForEachLevel.get(水平);我++){
如果(ⅰ= groupPosition&放大器;!&放大器; listView.isGroupExpanded(ⅰ)){
listView.collapseGroup(ⅰ);
为(中间体II =等级+ 1; II蛋白酶minimumHeights.size();ⅱ++){
minimumHeights.set(二,0);
}
}
}
}
}
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState); groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5); minimumHeights.ensureCapacity(groupsForEachLevel.size());
allLevelViews.ensureCapacity(groupsForEachLevel.size());
的for(int i = 0; I< groupsForEachLevel.size();我++){
minimumHeights.add(0);
allLevelViews.add(NULL);
}
minimumHeights.set(0,1500);
的setContentView(R.layout.activity_main); ExpandableListView topLevelListView =
(ExpandableListView)findViewById(R.id.TopLevelList);
CustomListAdapter customListAdapter =新CustomListAdapter(0); topLevelListView.setOnGroupExpandListener(新ExpandChecker(topLevelListView,0));
topLevelListView.setAdapter(customListAdapter); minimumHeights.set(0,topLevelListView.getHeight());
allLevelViews.set(0,topLevelListView); } 公共类CustomListAdapter扩展BaseExpandableListAdapter { 私人NextLevelListView nextLevelListView;
私人最终诠释水平;
私人最终诠释lastLevel;
私人诠释overAllHeight;
私人最终诠释groupsInThisLevel;
私人最终诠释childCount; 公共CustomListAdapter(INT级){
超(); this.level =水平;
this.groupsInThisLevel = groupsForEachLevel.get(水平);
this.childCount = 1;
lastLevel = groupsForEachLevel.size();
} @覆盖
公共对象getChild(INT groupPosition,诠释childPosition){
W(*****,getChild);
返回nextLevelListView;
} @覆盖
众长getChildId(INT groupPosition,诠释childPosition){
W(*****,getChildId);
返回childPosition;
} @覆盖
公共查看getChildView(INT groupPosition,诠释childPosition,
布尔isLastChild,查看convertView,父母的ViewGroup){
W(*****,onChildView - 父类=+ parent.getClass()的getName());
INT nextLevel = this.level + 1;
Log.w(****,getChildView水平=+级); 如果(nextLevel< = lastLevel){
Log.w(****,getChildView 1 nextLevel =+ nextLevel);
CustomListAdapter customListAdapter =新CustomListAdapter(nextLevel);
Log.w(****,getChildView 2 nextLevel =+ nextLevel); nextLevelListView =(NextLevelListView)findViewById(R.id.NextLevelList);
Log.w(****,getChildView 3 nextLevel =+ nextLevel); nextLevelListView.setLevel(nextLevel);
nextLevelListView.setGroupIndicator(NULL);
nextLevelListView.setOnGroupExpandListener(新
ExpandChecker(nextLevelListView,nextLevel));
nextLevelListView.setAdapter(customListAdapter);
Log.w(****,getChildView 4 nextLevel =+ nextLevel);
返回nextLevelListView;
}
返回null;
} @覆盖
公众诠释getChildrenCount(INT groupPosition){
W(*****,getChildrenCount+ childCount);
返回childCount;
} @覆盖
公共对象getGroup(INT groupPosition){
W(*****,getGroup); 返回groupPosition;
} @覆盖
公众诠释getGroupCount(){
W(*****,getGroupCount+ groupsInThisLevel);
返回this.groupsInThisLevel;
} @覆盖
众长getGroupId(INT groupPosition){
W(*****,getGroupId+ groupPosition);
返回groupPosition;
} @覆盖
公共查看getGroupView(最终诠释groupPosition,布尔isExpanded,
查看convertView,父母的ViewGroup){ Log.w(****,getCGroupView 1级=+级); 如果(convertView == NULL){
LayoutInflater layoutInflater = MainActivity.this.getLayoutInflater();
convertView = layoutInflater.inflate(R.layout.all_levels_text,NULL);
}
Log.w(****,getCGroupView 2级=+级); TextView的项目=(TextView中)convertView.findViewById(R.id.TextItem); 如果(水平== 0){
item.setBackgroundColor(Color.CYAN);
}否则如果(水平== groupsForEachLevel.size() - 1){
item.setBackgroundColor(Color.GREEN);
}其他{
item.setBackgroundColor(Color.LTGRAY);
} item.setText(Integer.toString(级)+ - + Integer.toString(groupPosition));
item.setPadding(30 *(等级+ 1),0,0,0); 如果(水平==(groupsForEachLevel.size() - 1)){
convertView.setOnClickListener(新OnClickListener(){ @覆盖
公共无效的onClick(查看视图){
W(****,中点击监听器 - 未来的行动尚未设置);
}
});
}
如果(groupPosition ==(groupsInThisLevel - 1)
&功放;&安培; parent.getHeight()!= 0
&功放;&安培; minimumHeights.get(水平)== 0){
的for(int i =水平; I> = 0;我 - ){
minimumHeights.set(ⅰ,minimumHeights.get(I)+ parent.getMeasuredHeight());
} allLevelViews.set(水平,父母);
Log.w(****,添加到阵列母体L =+
等级+
TYPE =+
allLevelViews.get(水平).getClass()的getName()+
+
minimumHeights.toString()+
+
((ExpandableListView)allLevelViews.get(水平))的getHeight());
} 返回convertView;
} @覆盖
公共布尔hasStableIds(){
返回false;
} @覆盖
公共布尔isChildSelectable(INT groupPosition,诠释childPosition){
返回true;
}
}}
NextLevelListView.java
包com.multilevellist;进口android.content.Context;
进口android.util.AttributeSet;
进口android.widget.ExpandableListView;引入静态android.util.Log.w;公共类NextLevelListView扩展ExpandableListView { 私人INT水平= 0; 公共NextLevelListView(上下文的背景下){
超级(上下文);
} 公共NextLevelListView(上下文的背景下,AttributeSet中的AttributeSet){
超(上下文,属性集中);
} @覆盖
公共无效onMeasure(INT宽度,高度INT){
W(*****,onMeasure 1);
身高= MeasureSpec.makeMeasureSpec(1500,MeasureSpec.AT_MOST);
W(*****,onMeasure 2);
super.onMeasure(宽度,高度);
W(*****,onMeasure 3);
} 公共无效执行setLevel(INT级){
this.level =水平;
}
}
使用 com.multilevellist.MainActivity $ NextLevelListView
而不是 com.multilevellist。 MainActivity.NextLevelListView
XML格式。该XML通货膨胀使用Java反射来查找类。在Java反射, $
从他们的父母区分嵌套类。
I have an expandablelist which contains multiple groups, each of which contains a single child which is an expandablelist with multiple groups each of which also contain a single child which contains another expandablelist..................and so down the levels.
03-17 23:37:30.508 1751-1751/com.multilevellist E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.multilevellist, PID: 1751
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
cannot be cast to android.widget.AbsListView$LayoutParams
at android.widget.ListView.setupChild(ListView.java:1826)
at android.widget.ListView.makeAndAddView(ListView.java:1793)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillSpecific(ListView.java:1349)
at android.widget.ListView.layoutChildren(ListView.java:1608)
at android.widget.AbsListView.onLayout(AbsListView.java:2091)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at com.android.internal.widget.ActionBarOverlayLayout.onLayout(
ActionBarOverlayLayout.java:374)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.multilevellist.MainActivity">
<ExpandableListView
android:id="@+id/TopLevelList"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#caa551"
android:choiceMode="singleChoice"
android:groupIndicator="@null"
android:scrollbars="vertical"></ExpandableListView>
<com.multilevellist.MainActivity.NextLevelListView
android:id="@+id/NextLevelList"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#41ca7e"
android:choiceMode="singleChoice"
android:groupIndicator="@null"
android:scrollbars="vertical"></com.multilevellist.MainActivity.NextLevelListView>
</RelativeLayout>
all_levels_text.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.newShop.MainActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="0dp"
android:id="@+id/all_levels_text">
<TextView
android:id="@+id/TextItem"
android:textColor="#000000"
android:textSize="15sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
MainActivity.java
package com.multilevellist;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnGroupExpandListener;
import android.widget.TextView;
import java.util.ArrayList;
import static android.util.Log.*;
public class MainActivity extends Activity {
private final ArrayList<Integer> groupsForEachLevel = new ArrayList<Integer>();
private static final ArrayList<Integer> minimumHeights = new ArrayList<Integer>();
private final ArrayList<Object> allLevelViews = new ArrayList<Object>();
public class ExpandChecker implements OnGroupExpandListener {
private ExpandableListView listView;
private int level;
public ExpandChecker(ExpandableListView listView, int level) {
w("*****", "onGroupExpand constructor level " + level);
this.listView = listView;
this.level = level;
}
@Override
public void onGroupExpand(int groupPosition) {
w("*****", "onGroupExpand " + level + " " + minimumHeights.toString());
for (int i = 0; i < groupsForEachLevel.get(level); i++) {
if (i != groupPosition && listView.isGroupExpanded(i)) {
listView.collapseGroup(i);
for (int ii = level + 1; ii < minimumHeights.size(); ii++) {
minimumHeights.set(ii, 0);
}
}
}
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
groupsForEachLevel.add(5);
minimumHeights.ensureCapacity(groupsForEachLevel.size());
allLevelViews.ensureCapacity(groupsForEachLevel.size());
for (int i = 0; i < groupsForEachLevel.size(); i++) {
minimumHeights.add(0);
allLevelViews.add(null);
}
minimumHeights.set(0, 1500);
setContentView(R.layout.activity_main);
ExpandableListView topLevelListView =
(ExpandableListView) findViewById(R.id.TopLevelList);
CustomListAdapter customListAdapter = new CustomListAdapter(0);
topLevelListView.setOnGroupExpandListener(new ExpandChecker(topLevelListView, 0));
topLevelListView.setAdapter(customListAdapter);
minimumHeights.set(0, topLevelListView.getHeight());
allLevelViews.set(0, topLevelListView);
}
public class CustomListAdapter extends BaseExpandableListAdapter {
private NextLevelListView nextLevelListView;
private final int level;
private final int lastLevel;
private int overAllHeight;
private final int groupsInThisLevel;
private final int childCount;
public CustomListAdapter(int level) {
super();
this.level = level;
this.groupsInThisLevel = groupsForEachLevel.get(level);
this.childCount = 1;
lastLevel = groupsForEachLevel.size();
}
@Override
public Object getChild(int groupPosition, int childPosition) {
w("*****", "getChild");
return nextLevelListView;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
w("*****", "getChildId");
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
w("*****", "onChildView - parent class=" + parent.getClass().getName());
int nextLevel = this.level + 1;
Log.w("****", "getChildView level=" + level);
if (nextLevel <= lastLevel) {
Log.w("****", "getChildView 1 nextLevel=" + nextLevel);
CustomListAdapter customListAdapter = new CustomListAdapter(nextLevel);
Log.w("****", "getChildView 2 nextLevel=" + nextLevel);
nextLevelListView = (NextLevelListView) findViewById(R.id.NextLevelList);
Log.w("****", "getChildView 3 nextLevel=" + nextLevel);
nextLevelListView.setLevel(nextLevel);
nextLevelListView.setGroupIndicator(null);
nextLevelListView.setOnGroupExpandListener(new
ExpandChecker(nextLevelListView, nextLevel));
nextLevelListView.setAdapter(customListAdapter);
Log.w("****", "getChildView 4 nextLevel=" + nextLevel);
return nextLevelListView;
}
return null;
}
@Override
public int getChildrenCount(int groupPosition) {
w("*****", "getChildrenCount " + childCount);
return childCount;
}
@Override
public Object getGroup(int groupPosition) {
w("*****", "getGroup");
return groupPosition;
}
@Override
public int getGroupCount() {
w("*****", "getGroupCount " + groupsInThisLevel);
return this.groupsInThisLevel;
}
@Override
public long getGroupId(int groupPosition) {
w("*****", "getGroupId " + groupPosition);
return groupPosition;
}
@Override
public View getGroupView(final int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Log.w("****", "getCGroupView 1 level=" + level);
if (convertView == null) {
LayoutInflater layoutInflater = MainActivity.this.getLayoutInflater();
convertView = layoutInflater.inflate(R.layout.all_levels_text, null);
}
Log.w("****", "getCGroupView 2 level=" + level);
TextView item = (TextView) convertView.findViewById(R.id.TextItem);
if (level == 0) {
item.setBackgroundColor(Color.CYAN);
} else if (level == groupsForEachLevel.size() - 1) {
item.setBackgroundColor(Color.GREEN);
} else {
item.setBackgroundColor(Color.LTGRAY);
}
item.setText(Integer.toString(level) + " -- " + Integer.toString(groupPosition));
item.setPadding(30 * (level + 1), 0, 0, 0);
if (level == (groupsForEachLevel.size() - 1)) {
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
w("****", "in click listener - future action not yet set ");
}
});
}
if (groupPosition == (groupsInThisLevel - 1)
&& parent.getHeight() != 0
&& minimumHeights.get(level) == 0) {
for (int i = level; i >= 0; i--) {
minimumHeights.set(i, minimumHeights.get(i) + parent.getMeasuredHeight());
}
allLevelViews.set(level, parent);
Log.w("****", "add to array parent l=" +
level +
" type=" +
allLevelViews.get(level).getClass().getName() +
" " +
minimumHeights.toString() +
" " +
((ExpandableListView) allLevelViews.get(level)).getHeight());
}
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
}
NextLevelListView.java
package com.multilevellist;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ExpandableListView;
import static android.util.Log.w;
public class NextLevelListView extends ExpandableListView {
private int level = 0;
public NextLevelListView(Context context ) {
super(context );
}
public NextLevelListView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
@Override
public void onMeasure(int width, int height) {
w("*****", "onMeasure 1 ");
height = MeasureSpec.makeMeasureSpec(1500, MeasureSpec.AT_MOST);
w("*****", "onMeasure 2 ");
super.onMeasure(width, height);
w("*****", "onMeasure 3 ");
}
public void setLevel(int level) {
this.level = level;
}
}
Use com.multilevellist.MainActivity$NextLevelListView
instead of com.multilevellist.MainActivity.NextLevelListView
in XML. The XML inflation uses Java reflection to find the classes. In Java reflection, $
distinguishes nested classes from their parents.
这篇关于错误充气类时,自定义类是嵌套类MainActivity的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!