私はページをスワップするために私のアプリケーションでviewflipperとgesturedetectorを使用しています。ページをスワップできます。今私はswapleftメソッドに関する私のアプリケーションの次の活動に行きたいです。 swapleftの 私は1つのメソッドpage.showNext()を追加しました。今度は次のアクティビティに切り替えたいと思います。次のアクティビティにスワイプする方法
がここにそれは私のactivity.class
public class eDetailing extends Activity
{
ViewFlipper page;
Animation animFlipInForeward;
Animation animFlipOutForeward;
Animation animFlipInBackward;
Animation animFlipOutBackward;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
page = (ViewFlipper)findViewById(R.id.main_flipper_view);
animFlipInForeward = AnimationUtils.loadAnimation(this, R.anim.flipin);
animFlipOutForeward = AnimationUtils.loadAnimation(this, R.anim.flipout);
animFlipInBackward = AnimationUtils.loadAnimation(this, R.anim.flipin_reverse);
animFlipOutBackward = AnimationUtils.loadAnimation(this, R.anim.flipout_reverse);
//findViewById(R.id.main_linear).setOnClickListener(this);
}
private void SwipeRight(){
page.setInAnimation(animFlipInBackward);
page.setOutAnimation(animFlipOutBackward);
page.showPrevious();
}
private void SwipeLeft(){
page.setInAnimation(animFlipInForeward);
page.setOutAnimation(animFlipOutForeward);
page.showNext();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
SimpleOnGestureListener simpleOnGestureListener
= new SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
float sensitvity = 50;
if((e1.getX() - e2.getX()) > sensitvity){
SwipeLeft();
}else if((e2.getX() - e1.getX()) > sensitvity){
SwipeRight();
}
return true;
}
};
GestureDetector gestureDetector
= new GestureDetector(simpleOnGestureListener);
}ここ
である、それは私のxmlファイル
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal">
<ViewFlipper
android:id="@+id/main_flipper_view"
android:layout_height="540dip" android:layout_width="1020dip">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="horizontal">
<ImageView android:id="@+id/main_imageview" android:background="@drawable/img_main" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView>
</LinearLayout>
</ViewFlipper>
と私はflipin、FLIPOUT、flipinreverseを使用していますで、アニメーションのflipoutreverse xmlファイル。 アイデアは誰にでもありますか?
また、私はアクティビティにメニューを追加したい、メニューは異なるページを操作する。 viewflipperとgesturedetectorを使用したページスワイプ効果で が可能ですか?
ありがとうございます。
のように行うことができます。 あなたはインテントを使って別のアクティビティ権に行くことができます。 – user1213202
http://stackoverflow.com/questions/5151591/android-left-to-right-slide-animation –