求助,为什么Fragment里Button点击事件没反应
yzzwd 2014-04-14 02:44:28 public class RightFragment extends Fragment{
Button btn_photoframe;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.right, container,false);
btn_photoframe = (Button) view.findViewById(R.id.btn_photoframe);
//return view;
return inflater.inflate(R.layout.right, container,false);
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
btn_photoframe.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(getActivity().getApplicationContext(), MainActivity.class);
startActivity(intent);
}
});
}
}