用于移动到多媒体资料中的下一张图片的按钮



我有两个按钮"Next"one_answers"Previous"。我希望它们移到我的图库中的下一张/上一张图片。我该如何设置按钮的侦听器来实现这一点?

如果这是你的自定义图库,那么你可以做下面的

将监听器添加到按钮

previousButton = (Button) findViewById(R.id.backButton);
        previousButton.setOnClickListener(this);
        nextButton = (Button) findViewById(R.id.nextButton);
        nextButton.setOnClickListener(this);

在onclick方法中设置图像

@Override
public void onClick(View view) {
    // TODO Auto-generated method stub
    if (view == previousButton) {
            --positionOfSelectedImage;
            // set background image of
        } else if (view == nextButton) {
            ++positionOfSelectedImage;
        }
imageToBeSet.setImageURI(Uri.parse(absolutepathOfImage));
}

谢谢Deepak

相关内容

最新更新