我尝试但是我遇到错误" Onclick听众无法在这里应用"请帮帮我们
这是我的Fragment.java
public class Fragment extends Fragment {
public Fragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_layout, container, false);
final Button button = (Button) rootView.findViewById(R.id.payment_info);
final Button button1 = (Button) rootView.findViewById(R.id.redeem);
final Button button2 = (Button) rootView.findViewById(R.id.make_payment);
final Button button3 = (Button) rootView.findViewById(R.id.payment_histories);
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
}
答案 0 :(得分:0)
OnClickListener是一个接口,因此您不必仅扩展片段,而是实现OnClick。
在你的班级宣言上试试这个:
public class Fragment extends Fragment implements OnClickListener
希望它有所帮助。