B
BenOtto
Fortgeschrittenes Mitglied
- 15
FlipperActivity.java
scroll.xml
PS: So Java Syntaxhighlighting für's Forum wäre schon cool!
Code:
package de.android_hilfe.benotto.viewflipper;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnTouchListener;
import android.widget.ViewFlipper;
public class FlipperActivity extends Activity {
ViewFlipper mFlipper;
GestureDetector mGestureDetector;
private class MyOnGestureListener extends SimpleOnGestureListener {
@Override
public void onLongPress(MotionEvent e) {
mFlipper.showNext();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scroll);
mGestureDetector = new GestureDetector(this, new MyOnGestureListener());
mFlipper = (ViewFlipper) findViewById(R.id.flipper);
mFlipper.setOnTouchListener(
new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean handled = mGestureDetector.onTouchEvent(event);
return handled;
}
}
);
}
}
scroll.xml
HTML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="200dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ABC" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DEF" />
</ViewFlipper>
</LinearLayout>
</ScrollView>
PS: So Java Syntaxhighlighting für's Forum wäre schon cool!