title: How to pass the data in between activity to fragment using intent in Android
body: <p>I can store the value in one variable now I want pass that variable into fragment.</p>
  
  <p>With the following code I am able to load fragments.</p>
  
  <pre><code>   public class AndroidListFragmentActivity extends Activity {
  Fragment2 f2;
  public static String itemname;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.apetiserfragement);
      itemname=getIntent().getStringExtra("itemname");
      Bundle args=new Bundle();
      args.putString("itemname", itemname);
      f2=new Fragment2();
      f2.setArguments(args);
  
  }
  }
  </code></pre>
  
  <p>(Here I load fragment using XML page) itemname</p>
  
  <p>The output is split into into 2 windows one for extend for listfragment(for listview). One for fragments</p>
  
  <p>Fragment2.xml</p>
  
  <pre><code>    public class Fragment2 extends Fragment {
  String itemname;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      // TODO Auto-generated method stub
  
      System.out.println(getArguments().getString("itemname"));
  
      return inflater.inflate(R.layout.fragment2, container, false);
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
  
  }
  
    }
  </code></pre>
  
  <p>AndroidListFragmentActivity in this class itemname I want pass Fragment2.class. </p>