KIO
Kreative Ideen online
Code example for "setContentView ()"

Code example for "setContentView ()"

SetContentView (): Set up the app’s user interface. You can consider your object or ID to this method as an argument.

Example:

[php] setContentView (R.layout.activity _ hello _ say); [/php]

Or

[php]Textview tv = new TextView (this); tv.setText ("Hello app developer!"); setContentView (tv); [/php]

Information about the parameters “R.layout.activity _ hello _ say.”

“R” is the name of a class that is automatically created for the project and whose job is resource management.

To learn the value of “activity _ hi _ say,” click right mouse button and in the context menu the command “Goto > Implementations.”

The “activity _ hello _ say”-ID comes from the resource file “activity _ hello _ sagen.xml.” Located in the subdirectory “app/res/layout”

In this example, “hardcoded …”

[php] <TextView android: Layout _ width = "wrap _ content" android: Text = "Hello World" /> [/php]

To outsource “hardcoded” string in resource file “String.xml …” Right mouse button … “Extract string”

Leave a Reply

Your email address will not be published. Required fields are marked *