Android neue View mit OnTouchListener

Hallo Leute,
ich hab ein problem:
Ich habe meine eigene View erstellt, welche einen OnTouchListener besitzt, dies will aber leider nicht funktionieren.

Java:
	 public class MyView extends View {
     
		 Canvas c;
		 
		 public MyView(Context context) {
             super(context);
             // TODO Auto-generated constructor stub
             this.setOnTouchListener(new OnTouchListener()
		     {
		     public boolean onTouch(View v, MotionEvent event)
		     {
		    	 float X = event.getX();
		    	 float Y = event.getY();
		    	 
		    	 switch (event.getAction()) {
		         case MotionEvent.ACTION_DOWN: 
		        	 
		        	 c.drawColor(Color.BLACK);
		        	 Paint p = new Paint();
		        	 p.setColor(Color.WHITE);
		        	 c.drawCircle(X, Y, 30, p);
		             break;

		         case MotionEvent.ACTION_MOVE:
		             
		             break;

		         case MotionEvent.ACTION_UP:   
		             
		             break;
		     }

		         return true;
		     }
		     });
         }
         
		 
		 
		 
         @Override
         protected void onDraw(Canvas canvas) {
            c = canvas;
        	 // TODO Auto-generated method stub
            super.onDraw(canvas);
            int x = getWidth();
            int y = getHeight();
            canvas.drawColor(Color.BLACK);
        }
     }
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
E Neue app erstellen Android & Cross-Platform Mobile Apps 3
T Android Android Augmented Faces in Java. Neue Landmarks erstellen Android & Cross-Platform Mobile Apps 1
B Android SQLite Tabelle neue Spalten hinzufügen Android & Cross-Platform Mobile Apps 8
J Android App stürzt ab wenn neue activity gestartet Android & Cross-Platform Mobile Apps 6
S Android neue Version des Programms wird nicht in Emulator geladen Android & Cross-Platform Mobile Apps 1
S Neue Activity lässt sich nicht starten Android & Cross-Platform Mobile Apps 28
D Android Neue Activity im TabWidget laden Android & Cross-Platform Mobile Apps 8
R Android Zugriff auf view von MainActivity Android & Cross-Platform Mobile Apps 7
W Zur Laufzeit erstelltes MenuItem an eine View binden Android & Cross-Platform Mobile Apps 1
W Bild aus dem Internet in View bzw. ImageView laden (Fragment) Android & Cross-Platform Mobile Apps 2
J View Breite/Höhe bestimmen Android & Cross-Platform Mobile Apps 4
B Android In einem View der ersten Activity zweite anzeigen Android & Cross-Platform Mobile Apps 2
S Dynamische EditText View eingaben in Datenbank speichern Android & Cross-Platform Mobile Apps 0
V PopUp in gleicher View anzeigen Android & Cross-Platform Mobile Apps 1
M Android Suche Activity/View Namen Android & Cross-Platform Mobile Apps 1
R Android Warum (View view)? Android & Cross-Platform Mobile Apps 4
B Eigene View xml-Layout einbinden Android & Cross-Platform Mobile Apps 1
R Problem mit View in ScrollView Android & Cross-Platform Mobile Apps 6
R Android Android.view Serializable ? Android & Cross-Platform Mobile Apps 3
M Android View zu View hinzufügen Android & Cross-Platform Mobile Apps 4
M Activity wechseln aus List View mit Android & Cross-Platform Mobile Apps 2
M Suche Name von View Komponente Android & Cross-Platform Mobile Apps 10
G canvas in view anzeigen Android & Cross-Platform Mobile Apps 10
G Fehlermeldung: "No XML content. Please add a root view or layout to your documet." Android & Cross-Platform Mobile Apps 7
E Android View zur Laufzeit hinzufügen Android & Cross-Platform Mobile Apps 4
N neuen view öffnen Android & Cross-Platform Mobile Apps 13
J id's von view komponenten werden nicht gefunden Android & Cross-Platform Mobile Apps 2
C Panel/View für Android Android & Cross-Platform Mobile Apps 3
tfa Android Layout-Probleme: View programmatisch erweitern (addContentView) Android & Cross-Platform Mobile Apps 7
G Dynamische View Inhalt -> Lagesensor Android & Cross-Platform Mobile Apps 3
G OnCLICKListener - OnTOUCHListener Android & Cross-Platform Mobile Apps 2
N Android OnTouchListener tut nichts Android & Cross-Platform Mobile Apps 3

Ähnliche Java Themen

Neue Themen


Oben