How to Add Java Objects to an Android
The Java language for Android has several objects you use to interface with users such as text boxes, layouts and text. You can use the Eclipse designer to create these objects, or dynamically create and display objects in the Java source code. Java objects are a part of constructing a user interface for your Android app.
Instructions
-
-
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);
-
1