gpt4 book ai didi

android - ListActivity 和 Activity 之间有什么区别?

转载 作者:太空狗 更新时间:2023-10-29 16:10:15 26 4
gpt4 key购买 nike

我需要将 Activity 更改为 ListActivity。但是我无法启动我的项目...我需要为此更改 manifest.xml 吗?

或者如何将屏幕从 Activity 更改为 ListActivity? startActivity(new Intent(this, list.class)) 有什么区别吗?

10-05 17:34:54.722: ERROR/AndroidRuntime(11550): java.lang.RuntimeException: Unable to start activity ComponentInfo{spexco.hus.cepvizyon/spexco.hus.cepvizyon.CepVizyon}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.os.Looper.loop(Looper.java:123)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread.main(ActivityThread.java:4363)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at java.lang.reflect.Method.invokeNative(Native Method)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at java.lang.reflect.Method.invoke(Method.java:521)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at dalvik.system.NativeStart.main(Native Method)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ListActivity.onContentChanged(ListActivity.java:236)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.Activity.setContentView(Activity.java:1622)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at spexco.hus.cepvizyon.CepVizyon.onCreate(CepVizyon.java:21)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
10-05 17:34:54.722: ERROR/AndroidRuntime(11550): ... 11 more
10-05 17:34:55.432: ERROR/PowerManagerService(129): setPowerState SystemProperties.get siBefornormal
10-05 17:35:01.872: ERROR/PowerManagerService(129): setPowerState SystemProperties.get siBefornormal




public class CepVizyon extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
ListView list=(ListView) findViewById(R.id.list);
ImageButton b1 = (ImageButton) findViewById(R.id.menu_mycameras);
ImageButton b2 = (ImageButton) findViewById(R.id.menu_aboutus);
ImageButton b3 = (ImageButton) findViewById(R.id.menu_help);

b1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Intent intent=new Intent(CepVizyon.this, CameraSelectScreen.class);
startActivity(intent);

// TODO Auto-generated method stub

}
});
b2.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Intent intent=new Intent(CepVizyon.this,MainActivity.class);
startActivity(intent);
// TODO Auto-generated method stub

}
});
b3.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub


}
});
}
}

这是我的课..

这是我的 main.xml 我不在那里使用列表,我把它放在错误堆栈中。但没有任何改变。

<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:layout_weight="3">

<ImageButton android:layout_weight="1" android:id="@+id/menu_mycameras"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/menu_cameras">
</ImageButton>
<ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" ></ListView>
<ImageButton
android:paddingTop="20px"
android:layout_weight="1" android:id="@+id/menu_aboutus"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/menu_aboutus">
</ImageButton>

<ImageButton android:layout_weight="1" android:id="@+id/menu_help"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/menu_help">
</ImageButton>

</LinearLayout>

最佳答案

您的 ListView 的 ID 必须是:“@android:id/list”。这样 ListActivity 就会找到它。

关于android - ListActivity 和 Activity 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3864546/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com