It's simple. The OnTouchListener does not work at all.
I'm fairly certain it's being initialized. I'm using a custom view to draw my UI, and as usual, I'm being impeded by Android's touchy API:
public class ViewInterface extends View implements OnTouchListener{
public ViewInterface(Context context){
super(context);
...
}
public void update(){
...
}
@Override
public void onDraw(Canvas canvas){
...
}
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
keyboardEnabled = true;
return true;
case MotionEvent.ACTION_UP:
keyboardEnabled = false;
return true;
default: break;
}
return false;
}
Code for initializing the view in the main activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
//setContentView(R.layout.activity_aidan);
activity = this;
viewInterface = new ViewInterface(this);
setContentView(viewInterface);
initializeSpeechRecognition();
findMe();
run.start();
}
What am I missing? Upon touching the screen and holding it, keyboardEnabled should be set to true (its just a debug value) - yet it does not do anything. The touch events don't seem to be responding at all.
0 comments:
Post a Comment