首页 文章

ActivityNotFoundException甚至为Fragment声明的操作

提问于
浏览
-2

我有以下代码:

public class Fragment1 extends Fragment implements View.OnClickListener {

    Button button;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        if(container == null )
            return null;

        View view = (LinearLayout)inflater.inflate(R.layout.fragment1_layout, container, false);
        button = (Button) view.findViewById(R.id.button);
        button.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {

        if(v.getId() == R.id.button) {
            startActivity(new Intent(getActivity().getApplicationContext(), Fragment3.class));
        }
    }
}

我开始使用Android,我甚至在manifestxt.xml中声明了一个活动:

活动android:name =“pachage ... destiny_fragment”

连续表现

E/AndroidRuntime﹕ FATAL EXCEPTION: main
    android.content.ActivityNotFoundException: Unable to find explicit activity class {eguias.delogic.com.br.eguiasmobile/eguias.delogic.com.br.eguiasmobile.Fragment3}; have you declared this activity in your AndroidManifest.xml?
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
            at android.app.Activity.startActivityForResult(Activity.java:3351)
            at android.app.Activity.startActivityForResult(Activity.java:3312)
            at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:826)
            at android.support.v4.app.Fragment.startActivity(Fragment.java:896)
            at eguias.delogic.com.br.eguiasmobile.Fragment1.onClick(Fragment1.java:37)
            at android.view.View.performClick(View.java:4084)
            at android.view.View$PerformClick.run(View.java:16966)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)

应用程序正常运行,但错误“android.content.ActivityNotFoundException”始终显示在logcat中 .

谢谢 .

2 回答

  • 0

    主要

    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.shamsan.droplivelast1/com.shamsan.droplivelast1.Reqlist}; have you declared this activity in your AndroidManifest.xml?
     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
     at android.app.Activity.startActivityForResult(Activity.java:3417)
    at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
    
  • 0

    你的 Fragment3.class 应该扩展 Activity ,这应该在 AndroidManifest.xml 中声明 .

相关问题