jxg*_*xgn 0 android image listener touch
我正在通过startActivityForResult()从gallery加载图像并在onActivity()中加载图像.我不能为该图像实现touchlistener吗?供参考见下文.
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == SELECT_PICTURE) {
......
......
Bitmap bitmapPreview = BitmapFactory.decodeFile(fileSrc); //load preview image
setimage.setImageBitmap(BitmapPreview);
setimage.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(getApplicationContext(), "Image touced!", Toast.LENGTH_SHORT).show();
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
小智 6
确保您需要正确导入侦听器
import android.view.View.OnTouchListener;
Run Code Online (Sandbox Code Playgroud)
在您的文件的顶部与其他导入.
| 归档时间: |
|
| 查看次数: |
13701 次 |
| 最近记录: |