1
我利用Viewpager在我的應用程序..向左或向右用戶刷卡的時候,我會告訴一個或下一個圖像 - 基本類應用與(圖像)的幻燈片..在ViewPager中翻轉?
如果用戶點擊應用程序,我想在ViewPager中翻轉視圖。每個視圖背後的視圖 - 用戶必須能夠在觀看時翻轉視圖。
這是代碼,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
.... <some code> ....
viewPager = (ViewPager) findViewById(R.id.main_viewpager);
ImagePagerAdapter adapter = new ImagePagerAdapter();
viewPager.setAdapter(adapter);
PageListener pageListener = new PageListener();
viewPager.setOnPageChangeListener((OnPageChangeListener) pageListener);
final GestureDetector tapGestureDetector = new GestureDetector(this, new TapGestureListener());
viewPager.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
tapGestureDetector.onTouchEvent(event);
return false;
}
});
}
private class TapGestureListener extends GestureDetector.SimpleOnGestureListener{
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// HERE I CAPTURED SINGLE TAP.. HOW DO I CHANGE THE VIEW OF VIEWPAGER?
return false;
}
}
我試着設置onTouchListener的ImageView,但正在努力。你可以請張貼一些代碼或指出一些實際的例子嗎? – Naveen
@確定,回答編輯! – lelloman
@Naveen這種方法沒有運氣? – lelloman