我无法覆盖 onSwipe() 方法。错误是“Adds 类型的 onSwipe(int) 方法必须覆盖或实现超类型方法”。谁能告诉我我做错了什么?我想使用滑动手势在活动之间导航。还有其他方法吗?如果是这样,请解释。我必须导入更多的包吗?
package com.mahavega.qcdemo;
import com.mahavega.qcdemo.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
public class Adds extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ads);
TextView tv1 = (TextView) findViewById(R.id.textView1);
tv1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Adds.this, Ads2.class));
}
});
ImageView im1 = (ImageView) findViewById(R.id.imageView1);
im1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Adds.this, Real.class));
}
});
}
@Override
public void onSwipe(int direction) {
Intent intent = new Intent();
switch (direction) {
case SimpleGestureFilter.SWIPE_RIGHT:
intent.setClass(this, Ads2.class);
break;
case SimpleGestureFilter.SWIPE_LEFT:
intent.setClass(this, Ads3.class);
break;
}
startActivity(intent);
}
}