set textview text programmatically android code example

Example 1: android studio set text of textview

// globally 
TextView myAwesomeTextView = (TextView)findViewById(R.id.myAwesomeTextView);

//in your OnCreate() method
myAwesomeTextView.setText("My Awesome Text");

Example 2: android studio textbox change text

XML:
<TextView
        android:id="@+id/helloTxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
        
Java:
TextView msg = findViewById(R.id.helloTxt);
msg.setText("Hello");

Example 3: android set text in textview programmatically from string resource

getResources().getString(R.string.nome_stringa])

Tags:

Misc Example