title: How to add Activity on Fragment Android
body: <p>This is a sample of my code, I want make a new application, and I want copy code from my previous project, but I get an error.</p>
  
  <p>HomeFragment.java (from Sliding Menu)</p>
  
  <pre><code>package com.example.sia;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup; 
  
  public class HomeFragment extends Fragment {
  
  public HomeFragment(){}
  
  @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
      return rootView;
  }
  }
  </code></pre>
  
  <p>Account.java</p>
  
  <pre><code>package com.example.sia2;
  
  import java.util.HashMap;
  
  import org.json.JSONArray;
  import android.os.Bundle;
  import android.app.Activity;
  import android.text.Html;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class Account extends Activity {
  
  Button logout;
  SessionManager session;
  TextView status;
  JSONArray contacts = null;
  String nim, name;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_my_account);
  
      session = new SessionManager(getApplicationContext());
      Toast.makeText(getApplicationContext(),
              "User Login Status: " + session.isLoggedIn(), Toast.LENGTH_LONG)
              .show();
  
      session.checkLogin();
  
      HashMap&lt;String, String&gt; user = session.getUserDetails();
  
      name = user.get(SessionManager.KEY_NAME);
      // id = user.get(SessionManager.KEY_ID);
  
      TextView status = (TextView) findViewById(R.id.status);
      status.setText(Html.fromHtml("Welcome,&lt;b&gt;" + name + "&lt;/b&gt;  "));
  
      logout = (Button) findViewById(R.id.logout);
  
      logout.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              session.logoutUser();
              finish();
          }
      });
  }
  
  }
  </code></pre>
  
  <p>I combine the code</p>
  
  <pre><code>package com.example.sia;
  
  import java.util.HashMap;
  
  import org.json.JSONArray;
  
  import com.example.sia.R;
  import com.example.sia.SessionManager;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.text.Html;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class HomeFragment extends Fragment {
  
  Button logout;
  SessionManager session;
  TextView status;
  JSONArray contacts = null;
  String nim, name;
  
  public HomeFragment(){}
  
  @Override
  /**public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_my_account);**/
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
  
  
      session = new SessionManager(getActivity().getApplicationContext());
      Toast.makeText(getActivity().getApplicationContext(),"User Login Status: " + session.isLoggedIn(), Toast.LENGTH_LONG).show();
  
      session.checkLogin();
  
      HashMap&lt;String, String&gt; user = session.getUserDetails();
  
      name = user.get(SessionManager.KEY_NAME);
      // id = user.get(SessionManager.KEY_ID);
  
      TextView status = (TextView) getView().findViewById(R.id.status);
      status.setText(Html.fromHtml("Welcome,&lt;b&gt;" + name + "&lt;/b&gt;  "));
  
      logout = (Button) getView().findViewById(R.id.logout);
  
      logout.setOnClickListener(new View.OnClickListener() 
      {
  
          @Override
          public void onClick(View arg0) 
          {
              // TODO Auto-generated method stub
              session.logoutUser();
              getActivity().finish();
          }
  
      });
      return rootView;  
  }  
  
  
  }    
  /*public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
      return rootView;
  }*/
  </code></pre>
  
  <p>I can launch the application, but when I open <code>fragment_home.xml</code>, it is not responding</p>
  
  <p>Thank you</p>