title: android: onclick event in listview using fragments
body: <p>please tell me how will i go on the next page when i click on listview..it goes on to next activty</p>
  
  <pre><code>import android.app.Fragment;
  import android.os.Bundle;
  import android.content.Intent;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.AdapterView;
  </code></pre>
  
  <p>public class FragMent1 extends Fragment {</p>
  
  <pre><code>private String arry[] = { "Tofeeq", "Ahmad", "Fragment", "Example",
          "Tofeeq", "Ahmad", "Fragment", "Example" };
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      ListView listView = new ListView(getActivity());
      ArrayAdapter&lt;String&gt; array = new ArrayAdapter&lt;String&gt;(getActivity(),
              android.R.layout.simple_list_item_1);
      for (String str : arry)
          array.add(str);
      listView.setAdapter(array);
      return listView;
      lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                  int position, long id) {
  
              Intent myIntent = new Intent(getActivity(), NextActivity.class);
              startActivity(myIntent);
          }
      });
  
      return root;
  
  }
  </code></pre>
  
  <p>}</p>