开始另一项活动

时间:2013-12-19 19:14:45

标签: android eclipse

也许你可以帮我解决我的问题。

我有一个linearLayout点击监听器,现在我想开始另一个活动。 但是在打开应用程序时我总是会遇到错误。

我的onClickPlaylistActivity中的失败是什么?

它适用于具有相同PlaylistActivity类的其他项目。是的,我已经在清单中声明了活动;)

非常感谢

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    viewFlipper = (ViewFlipper) findViewById(R.id.view_flipper);
    in_from_left = AnimationUtils.loadAnimation(this, R.anim.in_from_left);
    in_from_right = AnimationUtils.loadAnimation(this, R.anim.in_from_right);
    out_to_left = AnimationUtils.loadAnimation(this, R.anim.out_to_left);
    out_to_right = AnimationUtils.loadAnimation(this, R.anim.out_to_right);

    LinearLayoutTitel = (LinearLayout) findViewById(R.id.LinearLayoutTitelID);
    LinearLayoutAlben = (LinearLayout) findViewById(R.id.LinearLayoutAlbenID);
    LinearLayoutOrdner = (LinearLayout) findViewById(R.id.LinearLayoutOrdnerID);
    LinearLayoutInterpreten = (LinearLayout) findViewById(R.id.LinearLayoutInterpretenID);

    //get reference to the view flipper
      final ViewFlipper myViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper);
      //set the animation for the view that enters the screen
      myViewFlipper.setInAnimation(in_from_right);
      //set the animation for the view leaving th screen
      myViewFlipper.setOutAnimation(out_to_right);
      myViewFlipper.showNext();

      LinearLayoutTitel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent i = new Intent(getApplicationContext(), PlayListActivity.class);
            startActivityForResult(i, 100); 
            myViewFlipper.showPrevious();


        }
    });}}

和错误:

12-19 20:25:58.299: W/asset(21248): Copying FileAsset 0x50c81038 (zip:/data/app/de.vinzzenzz.musicplayeralpha-2.apk:/resources.arsc) to buffer size 10872 to make it aligned.
12-19 20:25:58.649: I/Adreno200-EGL(21248): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build:  (CL3449569)
12-19 20:25:58.649: I/Adreno200-EGL(21248): Build Date: 05/14/13 Tue
12-19 20:25:58.649: I/Adreno200-EGL(21248): Local Branch: htc2
12-19 20:25:58.649: I/Adreno200-EGL(21248): Remote Branch: 
12-19 20:25:58.649: I/Adreno200-EGL(21248): Local Patches: 
12-19 20:25:58.649: I/Adreno200-EGL(21248): Reconstruct Branch: 
12-19 20:25:58.789: D/qdmemalloc(21248): ion: Mapped buffer base:0x54019000 size:2088960 offset:0 fd:57
12-19 20:25:58.789: D/qdmemalloc(21248): ion: Mapped buffer base:0x40010000 size:4096 offset:0 fd:58
12-19 20:25:59.290: D/qdmemalloc(21248): ion: Mapped buffer base:0x5434d000 size:2088960 offset:0 fd:60
12-19 20:25:59.290: D/qdmemalloc(21248): ion: Mapped buffer base:0x40038000 size:4096 offset:0 fd:61
12-19 20:25:59.310: D/qdmemalloc(21248): ion: Mapped buffer base:0x5454b000 size:2088960 offset:0 fd:62
12-19 20:25:59.310: D/qdmemalloc(21248): ion: Mapped buffer base:0x4004f000 size:4096 offset:0 fd:63
12-19 20:26:00.321: D/qdmemalloc(21248): ion: Mapped buffer base:0x54879000 size:2088960 offset:0 fd:65
12-19 20:26:00.321: D/qdmemalloc(21248): ion: Mapped buffer base:0x40d3e000 size:4096 offset:0 fd:66
12-19 20:26:00.341: D/qdmemalloc(21248): ion: Mapped buffer base:0x54a77000 size:2088960 offset:0 fd:67
12-19 20:26:00.341: D/qdmemalloc(21248): ion: Mapped buffer base:0x40ec2000 size:4096 offset:0 fd:68
12-19 20:26:00.351: D/qdmemalloc(21248): ion: Mapped buffer base:0x54c75000 size:2088960 offset:0 fd:69
12-19 20:26:00.351: D/qdmemalloc(21248): ion: Mapped buffer base:0x411f2000 size:4096 offset:0 fd:70
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x54019000 size:2088960
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x40010000 size:4096
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x5434d000 size:2088960
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x40038000 size:4096
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x5454b000 size:2088960
12-19 20:26:00.361: D/qdmemalloc(21248): ion: Unmapping buffer  base:0x4004f000 size:4096
12-19 20:26:01.282: W/dalvikvm(21248): threadid=1: thread exiting with uncaught exception (group=0x417a0ba0)
12-19 20:26:01.282: E/AndroidRuntime(21248): FATAL EXCEPTION: main
12-19 20:26:01.282: E/AndroidRuntime(21248): android.content.ActivityNotFoundException: Unable to find explicit activity class {de.vinzzenzz.musicplayeralpha/de.vinzzenzz.musicplayeralpha.PlayListActivity}; have you declared this activity in your AndroidManifest.xml?
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.app.Instrumentation.execStartActivity(Instrumentation.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.app.Activity.startActivityForResult(Activity.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.app.Activity.startActivityForResult(Activity.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at de.vinzzenzz.musicplayeralpha.BrowseActivity$1.onClick(BrowseActivity.java:58)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.view.View.performClick(View.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.view.View$PerformClick.run(View.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.os.Handler.handleCallback(Handler.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.os.Handler.dispatchMessage(Handler.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.os.Looper.loop(Looper.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at android.app.ActivityThread.main(ActivityThread.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at java.lang.reflect.Method.invokeNative(Native Method)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at java.lang.reflect.Method.invoke(Method.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
12-19 20:26:01.282: E/AndroidRuntime(21248):    at dalvik.system.NativeStart.main(Native Method)

3 个答案:

答案 0 :(得分:2)

我认为Klaus66是对的,你可能错过了在清单文件中声明你的活动

<activity android:name="PlayListActivity"
          android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.example.app.PLAYLISTACTIVITY" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

你可以像这样调用这个活动

Intent i = new Intent("com.example.app.PLAYLISTACTIVITY");
startActivity(i);

答案 1 :(得分:1)

您是否在 Manifest 文件中声明了 PlayListActivity

答案 2 :(得分:1)

这是您的错误,它会告诉您所有事项,包括如何解决您的问题:)

  

android.content.ActivityNotFoundException:无法找到显式活动类{de.vinzzenzz.musicplayeralpha / de.vinzzenzz.musicplayeralpha.PlayListActivity}; 您是否在AndroidManifest.xml中声明了此活动?

在AndroidManifest中添加PlayListActivity声明:

<activity android:name=".PlayListActivity"></activity>