Android Basics – How to use findViewById method

If you want to reference any UI component, defined in the Layout XML file, then you need to use the findViewById method.

In your Activity class add the following code snippet

TextView helloText = (TextView) findViewById(;
if(helloText != null){
Log.v(TAG, “Lets check the value in hello id “+helloText.getText());

Once you get a reference you can perform operations on the element.