我的OneFragment.java代码:
public class OneFragment extends Fragment{
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_one, container, false);
}
public void gotofillhealth(View view){
Intent gotofh = new Intent(getActivity(),HealthFragment.class);
startActivity(gotofh);
}
}
我无法在“属性”选项卡上选择OnClick事件的方法。
我试过这段代码:
public class OneFragment extends Fragment implements View.OnClickListener{
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_one, container, false);
}
@Override
public void onClick(View v) {
Intent gotofh = new Intent(getActivity(),HealthFragment.class);
startActivity(gotofh);
}
}