title: How to use string builder?
body: <p>I want to display following output: 
     NAME : <strong><em>_</em></strong> 
      USN : <strong><em>_</em></strong> 
  ADDRESS : <strong><em>_</em></strong></p>
  
  <p>I want to display it in a single text view. When I tried using 2 text views it worked. But to use a single text view I used String builder, But when i click submit button, My application gets crashed. Why it's happening?</p>
  
  <pre><code>                    /*main.xml*/
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.assignment3.MainActivity"
      tools:ignore="MergeRootFrame" &gt;
  
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:layout_marginTop="20dp"
          android:paddingLeft="43dp"
          android:text="@string/name" /&gt;
  
      &lt;EditText
          android:id="@+id/edit_name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="95dp"
          android:gravity="center"
          android:inputType="textMultiLine"
          android:hint="@string/edit_name" /&gt;
  
      &lt;TextView
          android:id="@+id/usn"
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:layout_below="@+id/name"
          android:layout_marginTop="30dp"
          android:paddingLeft="52dp"
          android:text="@string/usn" /&gt;
  
      &lt;EditText
          android:id="@+id/edit_usn"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/edit_name"
          android:layout_marginLeft="95dp"
          android:layout_marginTop="10dp"
          android:gravity="center"
          android:inputType="textMultiLine"
          android:hint="@string/edit_usn" /&gt;
  
      &lt;TextView
          android:id="@+id/add"
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:layout_below="@+id/usn"
          android:layout_marginTop="40dp"
          android:paddingLeft="20.3dp"
          android:text="@string/add" /&gt;
  
      &lt;EditText
          android:id="@+id/edit_add"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/edit_usn"
          android:layout_marginLeft="95dp"
          android:layout_marginTop="20dp"
          android:gravity="center"
          android:inputType="textMultiLine"
          android:hint="@string/edit_add" /&gt;
      &lt;Button 
          android:id="@+id/submit"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="230dp"
          android:layout_centerHorizontal="true"
          android:text="@string/submit"/&gt;
  
  &lt;/RelativeLayout&gt;
  
  
            /*layout file*/
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;string name="app_name"&gt;Student Application Form&lt;/string&gt;
      &lt;string name="name"&gt;NAME :&lt;/string&gt;
      &lt;string name="edit_name"&gt;Enter your Name&lt;/string&gt;
      &lt;string name="usn"&gt;USN :&lt;/string&gt;
      &lt;string name="edit_usn"&gt;Enter the Usn&lt;/string&gt;
      &lt;string name="add"&gt;ADDRESS :&lt;/string&gt;
      &lt;string name="edit_add"&gt;Enter the Address&lt;/string&gt;
      &lt;string name="submit"&gt;Submit&lt;/string&gt;
      &lt;string name="number"&gt;1.&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="title_activity_details"&gt;Details&lt;/string&gt;
      &lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
  
  &lt;/resources&gt;
  
                   /*Activity_details.xml*/
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.assignment3.MainActivity"
      tools:ignore="MergeRootFrame" &gt;
  
      &lt;TextView
          android:id="@+id/number"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingTop="5dp"
          android:text="@string/number"
          android:textStyle="bold" /&gt;
  
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="12dp"
          android:paddingLeft="43dp"
          android:text="@string/name"
          android:textStyle="bold" /&gt;
  
      &lt;TextView
          android:id="@+id/usn"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/name"
          android:layout_marginTop="15dp"
          android:paddingLeft="52dp" 
          android:text="@string/usn"
          android:textStyle="bold"/&gt;
  
      &lt;TextView
          android:id="@+id/add"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/usn"
          android:layout_marginTop="20dp"
          android:paddingLeft="20.3dp"
          android:text="@string/add"
          android:textStyle="bold" /&gt;
  
  
  &lt;/RelativeLayout&gt;
            /*Main Activity.java*/
  package com.example.assignment4;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends ActionBarActivity implements OnClickListener{
      Button btn;
      EditText etext1;
      EditText etext2;
      EditText etext3;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          etext1 = (EditText) findViewById(R.id.edit_name);
          etext2 = (EditText) findViewById(R.id.edit_usn);
          etext3 = (EditText) findViewById(R.id.edit_add);
          /** Called when the user clicks the Submit button */
          btn.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View v) {
          Intent intent = new Intent(this, DetailsActivity.class);
          intent.putExtra("name", etext1.getText().toString());
          intent.putExtra("usn", etext2.getText().toString());
          intent.putExtra("address", etext3.getText().toString());
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>I passed the intent from this class to Details class. But when I click submit,it gets crashed. But Before it was working properly. After I added string builder, it started giving problem.</p>
  
  <pre><code>           /*Details.java*/
  </code></pre>
  
  <p>package com.example.assignment3;</p>
  
  <pre><code>import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.widget.TextView;
  
      public class Details extends ActionBarActivity {
          TextView text1;
          TextView text2;
          TextView text3;
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_details);
  
              //Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD);
              //String Builder to append strings
              StringBuilder sb1=new StringBuilder();
              StringBuilder sb2=new StringBuilder();
              StringBuilder sb3=new StringBuilder();
              //Receiving the intent
              Intent intent=getIntent();
              //Extracting the string 
              String Name=intent.getStringExtra("name");
              String Usn=intent.getStringExtra("usn");
              String Address=intent.getStringExtra("address");
              //get the string from a textview
              String stext1=getString(R.id.name);
              sb1.append(stext1);
              sb1.append(Name);
              text1.setText(sb1);
              String stext2=getString(R.id.usn);
              sb2.append(stext2);
              sb2.append(Usn);
              text2.setText(sb2);
              String stext3=getString(R.id.add);
              sb3.append(stext3);
              sb3.append(Address);
              text3.setText(sb3);
  
          }
  
      }
  </code></pre>
  
  <p>I'm getting Run Time Exception and Null Pointer exception in Logcat</p>