Friday, March 22, 2013

How to Add Java Objects to an Android



1. Open the Eclipse software and open your Java Android app in the software. Double-click the file you want to edit to load it in the editor.

2. Create the object. For instance, the following code creates a TextView object:TextView text = new TextView(this);The class object is 'TextView' and the variable assigned to the object is 'text.'

3. Add the object's parameters. For a TextView object, you must add text to the screen. The following code shows you how to set the text:text.setText('This is your text');Replace the 'This is your text' with your own.

4. Display the object to the user. After you set the object's parameters, use the following code to display the object on the screen:setContentView(text);

No comments:

Post a Comment