package com.example.dell.otheractivity;import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ExpandableListActivity extends android.app.ExpandableListActivity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ExpandableListAdapter adapter = new BaseExpandableListAdapter() {
int[] logos = new int[]
{
R.drawable.c1,R.drawable.c2,R.drawable.c3
};
private String[] armTypes = new String[]
{
"神","人","虫"
};
private String[][] arms = new String[][]
{
{"狂战","龙骑","暗黑圣堂","电兵"},
{"小狗","刺蛇","飞龙","自爆飞机"},
{"机枪兵","护士","幽灵"}
};
//获取指定组位置、指定子列表项
@Override
public Object getChild(int groupPosition, int childPosition) {
return arms[groupPosition][childPosition];
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
return arms[groupPosition].length;
}
private TextView getTextView()
{
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,64);
TextView textView = new TextView( ExpandableListActivity.this);
textView.setLayoutParams(lp);
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
textView.setPadding(36,0,0,0);
textView.setTextSize(20);
return textView;
} //该方法决定每个子选项的外观
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
TextView textView = getTextView();
textView.setText(getChild(groupPosition,childPosition).toString());
return textView;
} //获取指定位置处的数据
@Override
public Object getGroup(int groupPosition) {
return armTypes[groupPosition];
}
@Override
public int getGroupCount() {
return armTypes.length;
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
//该方法决定每个组选项的外观
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LinearLayout ll = new LinearLayout( ExpandableListActivity.this);
ll.setOrientation(0);
ImageView logo = new ImageView( ExpandableListActivity.this);
logo.setImageResource(logos[groupPosition]);
ll.addView(logo);
TextView textView = getTextView();
textView.setText(getGroup(groupPosition).toString());
ll.addView(textView);
return ll;
} @Override
public boolean hasStableIds() {
return true;
} @Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
};
setListAdapter(adapter);
}
}android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.dell.otheractivity/android.app.ExpandableListActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
at android.app.Activity.startActivityForResult(Activity.java:3441)
at android.app.Activity.startActivityForResult(Activity.java:3402)
at android.app.Activity.startActivity(Activity.java:3644)
at android.app.Activity.startActivity(Activity.java:3612)
at android.app.LauncherActivity.onListItemClick(LauncherActivity.java:404)
at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1129)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2927)
at android.widget.AbsListView$3.run(AbsListView.java:3676)
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:5050)
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:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ExpandableListActivity extends android.app.ExpandableListActivity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ExpandableListAdapter adapter = new BaseExpandableListAdapter() {
int[] logos = new int[]
{
R.drawable.c1,R.drawable.c2,R.drawable.c3
};
private String[] armTypes = new String[]
{
"神","人","虫"
};
private String[][] arms = new String[][]
{
{"狂战","龙骑","暗黑圣堂","电兵"},
{"小狗","刺蛇","飞龙","自爆飞机"},
{"机枪兵","护士","幽灵"}
};
//获取指定组位置、指定子列表项
@Override
public Object getChild(int groupPosition, int childPosition) {
return arms[groupPosition][childPosition];
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
return arms[groupPosition].length;
}
private TextView getTextView()
{
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,64);
TextView textView = new TextView( ExpandableListActivity.this);
textView.setLayoutParams(lp);
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
textView.setPadding(36,0,0,0);
textView.setTextSize(20);
return textView;
} //该方法决定每个子选项的外观
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
TextView textView = getTextView();
textView.setText(getChild(groupPosition,childPosition).toString());
return textView;
} //获取指定位置处的数据
@Override
public Object getGroup(int groupPosition) {
return armTypes[groupPosition];
}
@Override
public int getGroupCount() {
return armTypes.length;
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
//该方法决定每个组选项的外观
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LinearLayout ll = new LinearLayout( ExpandableListActivity.this);
ll.setOrientation(0);
ImageView logo = new ImageView( ExpandableListActivity.this);
logo.setImageResource(logos[groupPosition]);
ll.addView(logo);
TextView textView = getTextView();
textView.setText(getGroup(groupPosition).toString());
ll.addView(textView);
return ll;
} @Override
public boolean hasStableIds() {
return true;
} @Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
};
setListAdapter(adapter);
}
}android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.dell.otheractivity/android.app.ExpandableListActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
at android.app.Activity.startActivityForResult(Activity.java:3441)
at android.app.Activity.startActivityForResult(Activity.java:3402)
at android.app.Activity.startActivity(Activity.java:3644)
at android.app.Activity.startActivity(Activity.java:3612)
at android.app.LauncherActivity.onListItemClick(LauncherActivity.java:404)
at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1129)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2927)
at android.widget.AbsListView$3.run(AbsListView.java:3676)
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:5050)
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:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
解决方案 »
- 如何在Android/iOS游戏中集成社交分享按钮(新浪微博)
- 通过java程序给string.xml传值,我是这么写的但是显示却不对,请各位仁兄帮忙,谢谢!
- 怎么做一个程序的启动画面,然后立即跳到软件操作界面?
- TranslateAnimation问题
- ubuntu下设置android开发环境错误
- 设置初始化音乐音量问题
- 求救:如何获取图片的分辨率
- android 连接远程mysql数据库无法连接
- Fragment 切换
- RecyclerView适配器onBindViewHolder方法执行
- android 按返回键程序没反回到前一个activity 直接关掉了
- android 图片加载的框架都有哪些呢?
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.dell.otheractivity/android.app.ExpandableListActivity}; have you declared this activity in your AndroidManifest.xml?
错误信息显示的你显示调用的Activity是android.app.ExpandableListActivity,你调用的时候导错包了吧