Get Your Device for Android

Showing posts with label a. Show all posts
Showing posts with label a. Show all posts

Monday, December 19, 2011

Create Your Beyond First Android App (Part 2)


Hello again! Welcome to part 2 of this tutorial. Now, we will learn about Connecting UI control, Intent, Thread, and MediaPlayer

1. Connect UI to Code

If you want to take control with your Button, TextView, EditText, etc. You can use this instantiate:

Object UI name = (Object UI)findViewById(resource);

example:

Button myButton = (Button)findViewById(R.id.button1);

The example means that when you want to connect an UI component. You must create an Object to connect with your UI base on your component type. From the example: I want to connect button1 to code. So, I create a Button object named myButton that refers to the button1.