Friday, October 25, 2013

TextView in android:-

TextView can only display result as txt type of value.as well as String .that sit.

It's also use for know and required sum info which is hidden
Ex:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
 <Button
        android:id="@+id/bt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click Me" />

     <TextView
        android:id="@+id/tv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Click on the Button to change this text" />
   
</RelativeLayout>



MainActivity:-

package com.AmitSharma.textview;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
 Button button = (Button) findViewById(R.id.bt);  
button.setOnClickListener(new View.OnClickListener() {
          
           @Override
           public void onClick(View v) {
               // TODO Auto-generated method stub
              
               //Creating TextView Variable
               TextView text = (TextView) findViewById(R.id.tv);
              
               //Sets the new text to TextView (runtime click event)
               text.setText("You Have click the button");
           }
       });
  
   }
}

......................................................................................................................................................................................................................................................................................................................................


u can also give on there styles of text 
ex:-

<style name="TransparentActivity" >
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowFullscreen">false</item>
</style>




.............thank to u friends .............Look more again nd again .......... 

No comments:

Post a Comment