从片段开始活动

时间:2014-03-12 13:07:49

标签: android android-fragments fragment android-fragmentactivity

我得到的错误:ERROR here: can't connect to Play.cass

我做错了什么?

    public class AppleFragment extends Fragment implements OnItemClickListener,
    SensorEventListener {
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Log.i("list", "choose:" + musicList.get(arg2) + "this");

     Intent intent = new Intent();
     intent.setClass(getActivity(), Play.class);
   intent.putExtra("song", musicList.get(arg2));
   startActivity(intent);
}
  }

1 个答案:

答案 0 :(得分:1)

Intent intent = new Intent(getActivity(), Play.class);
 intent.putExtra("song", musicList.get(arg2));
 getActivity().startActivity(intent);