希望你很好,其實這是我第一篇文章,我搜索了很多 ,並且試了很多找到適合我的問題的解決方案,但 很遺憾找不到答案我的問題。WebView動畫問題 - Android
問題是: 我正在開發一個使用html,css和javascript的android應用程序。 我的應用程序依賴於Phonegap框架。 該應用程序由相當數量的本地頁面組成。在 應用程序中,我試圖處理android 移動設備上的滑動手勢事件,並根據滑動方向移動頁面。即如果 用戶向左滑動,則應用程序必須調用前一頁 ,然後如果用戶向右滑動,則應用程序將用戶轉發 到下一頁。
我可以使用原生Java爲Android做到這一點。但問題是, 在呼叫頁面時,我正在爲 請求的頁面做滑動效果。但會發生什麼是當前頁面所需的頁面效果不是 幻燈片效果 幻燈片 ,即所請求的頁面顯示:( 我正在尋找一種機制,使該效果影響 請求的本地頁面當前頁。我試圖拖延 動畫持續時間,但它變得太緩慢,所以就成了無聊 和BTW未能實現這一目標。
我希望你能幫助我在這個問題上,還是建議給我任何 方法或機制來達到這種效果
這是我的代碼:
public class App extends DroidGap {
/** Called when the activity is first created. */
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gestureDetector;
View.OnTouchListener gestureListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gestureDetector = new GestureDetector(new MyGestureDetector());
gestureListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
};
super.loadUrl("file:///android_asset/www/index.html");
}
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
// right to left swipe
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
appView.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_left));
appView.goBack();
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
appView.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_right_in));
appView.goForward();
}
} catch (Exception e) {
// nothing
}
return false;
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent e){
super.dispatchTouchEvent(e);
return gestureDetector.onTouchEvent(e);
}
}
由於提前, 阿納斯Jaghoub
請添加一些代碼來解釋你做了什麼,直到現在.. – 2011-03-28 09:34:51
我已經更新了帖子,其中包括用於處理刷卡事件的源代碼我做了什麼回去和前進 – 2011-03-29 07:48:16
永遠不會轉儲代碼,因爲它。刪除不需要/評論的部分並保持整潔。 – 2011-03-29 08:38:50