Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Can';不能从片段转到其他活动?_Android_Android Intent_Android Fragments - Fatal编程技术网

Android Can';不能从片段转到其他活动?

Android Can';不能从片段转到其他活动?,android,android-intent,android-fragments,Android,Android Intent,Android Fragments,我做这件事已经有一段时间了,但我没能成功。我正在使用fragment链接到其他活动(一个rapple),点击一个按钮,它就会崩溃。这是代码。有解决办法吗?非常感谢你的帮助 public class PagesFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View

我做这件事已经有一段时间了,但我没能成功。我正在使用fragment链接到其他活动(一个rapple),点击一个按钮,它就会崩溃。这是代码。有解决办法吗?非常感谢你的帮助

public class PagesFragment extends Fragment {


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

  View rootView =  inflater.inflate(R.layout.fragment_pages, container, false);

   Button mButton = (Button) rootView.findViewById(R.id.send);
   mButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          Intent i= new Intent("aforapple");
          startActivity(i);
      }
   });
   return rootView;
}
尝试使用:

       Intent i= new Intent(getActivity(),aforapple.class);
      getActivity().startActivity(i);
这样试试

   Intent i= new Intent(getActivity(),aforapple.class);
   getActivity().startActivity(i);
确保在
manifest.xml

有关更多信息,请访问以下网址:

Intent intent = new Intent(getActivity(), aforapple.class);
startActivity(intent);

发布logcat异常和清单文件。+1,谢谢!!!!我没有在manifest.xml中注册,非常感谢您的提醒,我被困了一段时间。。