GestureDetector构造器弃用
我想做一个有触屏滑动的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); }