如何通过了解我在屏幕上点击的x,y坐标来获取TextView中的文本(单词)? 感谢。
答案 0 :(得分:0)
检查以下代码..它与我合作正常,
public class ProjjActivity extends Activity {
TextView txtview;
float X,Y;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtview = (TextView) findViewById(R.id.tt);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
X = event.getX();
Y = event.getY();
txtview.setText("X: "+X+", Y: "+Y);
return super.onTouchEvent(event);
}
}
希望这可以帮助你......!