队
你能帮我调试一下这个问题吗?
ActivityAdapter activityAdapter = new ActivityAdapter(this,activityList); Log.d(“list”,“List Display - 1”);
setListAdapter( activityAdapter );
Log.d("List", "list done");
它在setListAdapter时抛出异常,
05-01 16:59:15.996:WARN / dalvikvm(251):threadid = 3:线程退出,未捕获异常(group = 0x4001b188) 05-01 16:59:15.996:ERROR / AndroidRuntime(251):未捕获的处理程序:由于未捕获的异常导致主线程退出 05-01 16:59:16.204:ERROR / AndroidRuntime(251):java.lang.RuntimeException:无法启动活动ComponentInfo {com.antennasoftware.xml / com.antennasoftware.xml.XMLParsing}:java.lang.RuntimeException:Your content必须有一个ListView,其id属性为'android.R.id.list' 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread.access $ 2200(ActivityThread.java:119) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1821) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.os.Handler.dispatchMessage(Handler.java:99) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.os.Looper.loop(Looper.java:123) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread.main(ActivityThread.java:4310) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at java.lang.reflect.Method.invokeNative(Native Method) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at java.lang.reflect.Method.invoke(Method.java:521) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:860) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at dalvik.system.NativeStart.main(Native Method) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):引起:java.lang.RuntimeException:您的内容必须有一个ListView,其id属性为'android.R.id.list' 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ListActivity.onContentChanged(ListActivity.java:236) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.Activity.setContentView(Activity.java:1622) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):at com.antennasoftware.xml.XMLParsing.onCreate(XMLParsing.java:36) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 05-01 16:59:16.204:ERROR / AndroidRuntime(251):... 11 more
class ActivityList扩展了LinearLayout {
public ActivityList(Context context, ActivityBean activityBean) {
super(context);
this.setOrientation(HORIZONTAL);
ListView listView = new ListView(context);
LinearLayout.LayoutParams idParams =
new LinearLayout.LayoutParams(100, LayoutParams.WRAP_CONTENT);
//cityParams.setMargins(10, 10, 10, 10);
TextView idColumn = new TextView( context );
idColumn.setText( activityBean.getActivityId() );
idColumn.setTextSize(14f);
idColumn.setTextColor(Color.WHITE);
listView.addView( idColumn, idParams);
LinearLayout.LayoutParams accountNameParams =
new LinearLayout.LayoutParams(20, LayoutParams.WRAP_CONTENT);
TextView accountNameView = new TextView(context);
accountNameView.setText( activityBean.getAccountName() );
accountNameView.setTextSize( 14f );
accountNameView.setTextColor(Color.WHITE);
listView.addView( accountNameView, accountNameParams);
LinearLayout.LayoutParams typeParams =
new LinearLayout.LayoutParams(25, LayoutParams.WRAP_CONTENT);
//ImageView skyControl = new ImageView( context );
TextView typeView = new TextView(context);
typeView .setText( activityBean.getAccountName() );
typeView.setTextSize( 14f );
typeView .setTextColor(Color.WHITE);
listView.addView( typeView, typeParams );
addView(listView);
}
}
公共类ActivityAdapter扩展了BaseAdapter {
public ActivityAdapter(Context context, List activityList) {
this.context = context;
this.activityList = activityList;
}
private Context context;
private List activityList;
@Override
public int getCount() {
// TODO Auto-generated method stub
return activityList.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ActivityBean activity = (ActivityBean) activityList.get(position);
return new ActivityList(this.context, activity );
}
}
提前致谢,
答案 0 :(得分:1)
您正在使用ListActivity,它要求您在内容XML中使用ID为“@id:android / list”
的ListView有关详细信息,请参阅documentation for ListActivity。
答案 1 :(得分:0)
java.lang.RuntimeException:你的 内容必须具有其ID的ListView 属性是'android.R.id.list'
您的XML视图文件是否包含格式正确的id字段:android:id="@id/android:list
用于相应的ListView标记?