我正在MainActivity
中实现onTouchListener
,并将一个OnTouchListener
属性分配给一个Textview tv
,但在运行时屏幕被按下时没有弹出消息。
MainActivity
public class MainActivity extends Activity implements View.OnTouchListener
{
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.tv);
tv.setOnTouchListener(this);
tv.setText(R.string.hello);
}
public boolean onTouch(View v,MotionEvent event)
{
Toast.makeText(this,"onTouch",Toast.LENGTH_LONG).show();
return true;
}
}