Android; Confused by views?

Posted by javano on Stack Overflow See other posts from Stack Overflow or by javano
Published on 2011-01-02T00:34:42Z Indexed on 2011/01/02 0:53 UTC
Read the original article Hit count: 260

Filed under:
|
|

I have created a class (InputControl) which extends the view of my main class (Main), and takes focus of the screen. I have a button on the main xml layout which calls control() and sets up my InputControl view, from there I capture user input.

How can I return back to the xml layout from the InputControl view class?

public class Main extends Activity {

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    InputControl = new InputControl(this);
}

//......SNIP!

public void control(){
setContentView(InputControl);
    InputControl.requestFocus();
}

}


public class InputControl extends View implements OnTouchListener {

public InputControl(Context context) {
    super(context);
    setFocusable(true);
    setFocusableInTouchMode(true);

    this.setOnTouchListener(this);

}


public boolean onTouch(View view, MotionEvent event) {

//...I AM CAPTURING USER TOUCH EVENTS HERE

}


}

© Stack Overflow or respective owner

Related posts about android

Related posts about view