我正在浏览我的第一个 viewpager 示例。它由两个片段组成,一个带有文本视图,一个带有图像视图。这是带有 imageview 的片段的代码:
public class ImageFragment extends Fragment {
private final int imageResourceId ;
public ImageFragment (int imageResourceId)
{
this.imageResourceId = imageResourceId;
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.e("Test","Hello");
}
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState)
{
View view = inflater.inflate(R.layout.image_layout, container,false);
ImageView imageView = (ImageView)view.findViewById(R.id.imageView1);
ImageView.setImageResource(imageResourceId);
return view;
}
}
如何为此图像视图实现点击处理程序?