you great God, I added in a sliding viewFlipper gestures, gestures to determine according to the sliding direction, then there is a simple toggle animation, but the run time error Unknown interpolator name: set I thought I was wrong xml definition of animation, but it is not found error ah
Here is the java code
public class ShowDataActivity extends Activity {
private QueryDataHandler query;
private ViewFlipper flipper;
private GestureDetector gesture;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
LinearLayout linear = new LinearLayout (this);
linear.setLayoutParams (new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
query = new QueryDataHandler (this);
gesture = new GestureDetector (this, new GestureDetector.OnGestureListener () {
@ Override
public boolean onDown (MotionEvent e) {
/ / TODO Auto-generated method stub
return false;
}
@ Override
public void onShowPress (MotionEvent e) {
/ / TODO Auto-generated method stub
}
@ Override
public boolean onSingleTapUp (MotionEvent e) {
/ / TODO Auto-generated method stub
return false;
}
@ Override
public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
return false;
}
@ Override
public void onLongPress (MotionEvent e) {
/ / TODO Auto-generated method stub
}
@ Override
public boolean onFling (MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
if (e2.getX () - e1.getX ()> 120)
{
Animation out = (Animation) AnimationUtils.loadInterpolator (ShowDataActivity.this, R.anim.push_right_out); / / this page from left to right to go out
Animation enter = (Animation) AnimationUtils.loadInterpolator (ShowDataActivity.this, R.anim.push_right_in) ;/ / Next from left to right into the
flipper.setInAnimation (enter);
flipper.setOutAnimation (out);
flipper.showPrevious ();
}
if (e2.getX () - e1.getX () <-120)
{
Animation in = (Animation) AnimationUtils.loadInterpolator (ShowDataActivity.this, R.anim.push_left_in); / / Next right to left into
Animation out = (Animation) AnimationUtils.loadInterpolator (ShowDataActivity.this, R.anim.push_left_out); / / this page from right to left out
flipper.setInAnimation (in);
flipper.setOutAnimation (out);
flipper.showNext ();
}
return false;
}
});
String rank = query.getCityAirQualityRank ();
Listlast10 = DataAnalysis.getLast10City (DataAnalysis.getCityAirQualitySorted (rank));
Listtop10 = DataAnalysis.getTop10City (DataAnalysis.getCityAirQualitySorted (rank));
RetangleDataView last10view = new RetangleDataView (this, last10);
RetangleDataView top10view = new RetangleDataView (this, top10);
flipper = new ViewFlipper (this);
flipper.addView (top10view, new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
flipper.addView (last10view, new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
linear.addView (flipper, new LinearLayout.LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView (linear);
}
public boolean onTouchEvent (MotionEvent event) {
return gesture.onTouchEvent (event); / / Register gesture events
}
}
Here is my definition animation xml
android: duration = "1500"
android: fromXDelta = "100% p"
android: toXDelta = "0" />android: duration = "1500"
android: fromAlpha = "0.1"
android: toAlpha = "1.0" />
Reply:
Alas, careless kill people ah. . . AnimationUtils wrong way
No comments:
Post a Comment