Android OnTouchListener tut nichts

noobee

Aktives Mitglied
es soll immo beim touch oder beim loslassen einfach nur in ein textfield was geschrieben werden. jedoch funzt das nicht. hier mal mein code:

Java:
package bla;

import android.os.Bundle;
...

public class MainActivity extends Activity implements OnTouchListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabs);
		TabHost th = (TabHost) findViewById(R.id.tabhost);
		th.setup();
		TabSpec specs;
		
		specs = th.newTabSpec("tag1");
		specs.setContent(R.id.tab1);
		specs.setIndicator("bla");
		th.addTab(specs);
		
		specs = th.newTabSpec("tag_2");
		specs.setContent(R.id.tab2);
		specs.setIndicator("blub");
		th.addTab(specs);
		
		specs = th.newTabSpec("tag_3");
		specs.setContent(R.id.tab3);
		specs.setIndicator("blör");
		th.addTab(specs);
		

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

///////////////////////////////////////////////////
	@Override
	public boolean onTouch(View v, MotionEvent event) {
		
		EditText et126 = (EditText) findViewById(R.id.EditText126);
		//et126.setTextColor(Color.GREEN);
		
		{
			int aktion = event.getAction();
		if (aktion == MotionEvent.ACTION_DOWN)
		{
			String a = "11";
			et126.setText(a);
			return true;
			}
		if (aktion == MotionEvent.ACTION_MOVE)
		{
			String a = "22";
			et126.setText(a);
			return true;
			}
		if (aktion == MotionEvent.ACTION_UP)
		{
			String a = "33";
			et126.setText(a);
			return true;
			}
		return false;
		}
	}
}

es gibt keinen fehler. woher sehe ich nun, was da falsch ist? irgendwas muss ja falsch sein ???:L
 
A

asdfghjl

Gast
oh, öhm was muss ich denn da wem wo zuweisen ? hab das so fast 1:1 ausm netz übernommen und da liefs :(
Da muss auf dem Weg zum aktuellen Code wohl etwas "verloren" gegangen sein.
z.B. seh ich in Deinem Code nirgends ein
Code:
setOnTouchListener
- Die mir einzig bekannte Möglichkeit einen OnTouchListener an einer View zu registrieren ;-)
 

Ähnliche Java Themen

Neue Themen


Oben