在片段中,方法没有出现在属性选项卡上?

时间:2017-01-18 08:27:31

标签: android android-layout android-fragments

我的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事件的方法。

CLICK FOR IMAGE

我试过这段代码:

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);
    }
}

0 个答案:

没有答案