Witam,
mam mały problem. Otóż chciałbym odczytać współrzędne, gdzie użytkownik dotknie palcem ekranu (w telefonach dotykowych).
Oto moje wypociny:
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.MotionEvent;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
float positionX;
float positionY;
/*public HelloAndroid(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("X: " + positionX + ",Y: " + positionY);
setContentView(tv);
}
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("X: " + positionX + ",Y: " + positionY);
setContentView(tv);
}
public void onGameLoop() {
}
public void onTouchDown(float x, float y, MotionEvent event, int pointerCount, int pointerId)
{
positionX = x;
positionY = y;
}
public void onTouchMove(float x, float y, MotionEvent event, int pointerCount, int pointerId)
{
}
public void onTouchUp(float x, float y, MotionEvent event, int pointerCount, int pointerId)
{
}
}
zadaniem tego programiku jest wypisanie w którym miejscu użytkownik dotknął ekranu. Niestety za każdym razem wyswietla się:
Co jest nie tak? Źle zrobiłem odczyt onTouch czy zromabłem wyświetlanie?
Byłbym wdzięczny za pomoc :help: :help: :help: