我想做一个有触屏滑动的activity,可是没有效果。在定义GestureDetector时,会提示这个构造器已经弃用,要加上忽视警告的语句:@SuppressWarnings("deprecation") 然后GestureDetector会被划上一条横线,我想知道有什么办法可以解决?新手求教! 我用的API是android 4.1部分代码:public class MainActivity extends Activity implements OnTouchListener, OnGestureListener {
TextView t;
private GestureDetector mGestureDetector;
@SuppressWarnings("deprecation")//
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t=(TextView)findViewById(R.id.text);
mGestureDetector = new GestureDetector(this); //这里会被横线划掉,是不是不能用了?有什么解决办法?
t.setOnTouchListener(this);
t.setFocusable(true);
t.setClickable(true);
t.setLongClickable(true);
mGestureDetector.setIsLongpressEnabled(true);
}
TextView t;
private GestureDetector mGestureDetector;
@SuppressWarnings("deprecation")//
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t=(TextView)findViewById(R.id.text);
mGestureDetector = new GestureDetector(this); //这里会被横线划掉,是不是不能用了?有什么解决办法?
t.setOnTouchListener(this);
t.setFocusable(true);
t.setClickable(true);
t.setLongClickable(true);
mGestureDetector.setIsLongpressEnabled(true);
}
public GestureDetector (Context context, GestureDetector.OnGestureListener listener)
你要是不需要直接把它null呗!new GestureDetector(this);这个构造过时了,不推荐使用了而已。