title: Performing Action inside the Fragment
body: <p>I have MainActivity that call Fragment, the fragment call class is:</p>
  
  <pre><code>public class Main extends Fragment{
  
      //public Main(){}
      Button btn;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
  
          final View rootView = inflater.inflate(R.layout.main, container, false);
          try{
              btn = (Button) rootView.findViewById(R.id.button1);
              btn.setOnClickListener(new OnClickListener(){
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      TextView tx = (TextView)rootView.findViewById(R.id.TextView04);
                      tx.setText("hello World");
                  }
  
              });
          }catch(Exception e){
  
          }
        // View rootView = inflater.inflate(R.layout.main, container, false);
         return rootView;
     }    
  
  }
  </code></pre>
  
  <p>my problem is, i'm not able to do some activity inside this fragment.
  just to find out how can i perform some activity inside this fragment i add a TextView and a Button that will change the text of TextView to "Hello World" when the button is clicked. now i try to run the application, every things fine but after clicking the button i'm getting error: "Unfprtunately the application has stopped.", i don't know why im getting error like this, i am new in android developing so please help and kindly please explain everything you add.</p>
  
  <pre><code>Here is the Log Cat Error:
  
  02-09 20:33:30.765: E/AndroidRuntime(13596): FATAL EXCEPTION: main
  02-09 20:33:30.765: E/AndroidRuntime(13596): java.lang.NullPointerException
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at info.androidhive.slidingmenu.Main$1.onClick(Main.java:29)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.view.View.performClick(View.java:4212)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.view.View$PerformClick.run(View.java:17476)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.os.Handler.handleCallback(Handler.java:800)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.os.Handler.dispatchMessage(Handler.java:100)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.os.Looper.loop(Looper.java:194)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at android.app.ActivityThread.main(ActivityThread.java:5371)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at java.lang.reflect.Method.invokeNative(Native Method)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at java.lang.reflect.Method.invoke(Method.java:525)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  02-09 20:33:30.765: E/AndroidRuntime(13596):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>