这是我注释了所需内容的代码。尝试了一些代码,但似乎与碎片不兼容。
public class main extends Fragment {
ImageButton imagebutton;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.main, container, false);
imagebutton = (ImageButton) rootView.findViewById(R.id.im);
imagebutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Open Yes/No Dialog
//if Yes do something
}
});
}
}