03-04 16:37:49.476:E / AndroidRuntime(29739):致命异常:主要 03-04 16:37:49.476:E / AndroidRuntime(29739):进程:com.h3ck.choicemobileno,PID:29739 03-04 16:37:49.476:E / AndroidRuntime(29739):android.content.ActivityNotFoundException:无法找到显式活动类{com.h3ck.choicemobileno / com.h3ck.choicemobileno.FragmentTwo};你有没有在AndroidManifest.xml中声明这个活动? 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Instrumentation.execStartActivity(Instrumentation.java:1541) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Activity.startActivityFromFragment(Activity.java:3957) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Activity.startActivityFromFragment(Activity.java:3932) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Fragment.startActivity(Fragment.java:1054) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Fragment.startActivity(Fragment.java:1033) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.h3ck.choicemobileno.FragmentTwo.onContextItemSelected(FragmentTwo.java:146) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Fragment.performContextItemSelected(Fragment.java:1821) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.FragmentManagerImpl.dispatchContextItemSelected(FragmentManager.java:1986) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.app.Activity.onMenuItemSelected(Activity.java:2623) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.policy.impl.PhoneWindow $ DialogMenuCallback.onMenuItemSelected(PhoneWindow.java:3878) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:741) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:884) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167) 03-04 16:37:49.476:E / AndroidRuntime(29739):at com.android.internal.app.AlertController $ AlertParams $ 3.onItemClick(AlertController.java:941) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.widget.AdapterView.performItemClick(AdapterView.java:299) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.widget.AbsListView.performItemClick(AbsListView.java:1113) 03-04 16:37:49.476:E / AndroidRuntime(29739):在android.widget.AbsListView $ PerformClick.run(AbsListView.java:2911)
Intent nt = new Intent(view.getContext().getApplicationContext(),
FragmentTwo.class);
startActivity(nt);
getActivity().finish();
Intent nt = new Intent(getActivity().getApplicationContext(),
FragmentTwo.class);
startActivity(nt);
getActivity().finish();
Intent nt = new Intent(getActivity().getApplicationContext(),
FragmentTwo.class);
startActivity(nt);
getActivity().finish();
/*FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
FragmentTwo llf = new FragmentTwo();
ft.replace(R.id.reservemobiledata, llf);
ft.commit();
*/
Intent intent = new Intent(getActivity(), FragmentTwo.class);
startActivity(intent);
如果有人有解决方案,那么请发布您宝贵的解决方案......
答案 0 :(得分:0)
您可以在要添加的视图的onCreateView方法中添加它
喜欢
yourView.setOnClickListener(new View.OnClickListener() { @override public onClick(View view) { ... } });
答案 1 :(得分:0)
我不太明白你在代码中尝试做什么,但你可以做到
public class FragmentOne extends Fragment implements OnClickListener
并添加未实现的方法来覆盖onClick方法。