Thursday 15 October 2015

Android: Accessing values in the TextView [ Label ]

       Android comes up with the element TextView that's the label.
Label plays a major roll in every applications for printing informations for the user. In android with TextView you could perform all kinds of operations that you do on label in Desktop applications which mainly includes getting and setting the values from the label! In this tutorial you're gonna learn how to use TextView for your android application.    



     *Copy and paste the java code in your activity class; where you want to access the label. And the xml code in your corresponding layout xml file.

Java:
 TextView label = (TextView) findViewById(R.id.textview1);  
 label .setText(“Welcome”);// to set value to the label  

XML:
<TextView  
     android:id="@+id/textview1"  
     android:layout_width="match_parent"  
     android:layout_height="150dp"  
     android:text="Hello World"  
     android:textAppearance="?android:attr/textAppearanceMedium" />  

No comments:

Post a Comment