Thursday, 20 March 2014

Getting TextView empty from Code in Android

Demonstrating step by step procedure to make the text view blank from code ;

1. Place the Text view into Layout Xml file like below;

<TextView
        android:id="@+id/txtAlphabat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imgvAlpha"
        android:layout_toRightOf="@+id/imgvAlpha"
        android:text=" - Apple"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#c4de66"
        android:textSize="26sp"

        android:textStyle="bold" />

2. Create object of it into Java file;

private TextView txtAlphabat;

txtAlphabat = (TextView) findViewById(R.id.txtAlphabat);


3. Make the textview blank by code
txtAlphabat.setText("");


No comments:

Post a Comment