Want to start an activity from listview click but my class does not extend activity <p>I have a listview in viewpager. I want to start a new activity or if that possible, to make same activity for multiple xml, if I click on item in that list view. </p> <p>But my class does not extend activity.</p> <p>This is my code:</p> <pre><code> public class SampleListFragment extends ScrollTabHolderFragment implements OnScrollListener { private static final String ARG_POSITION = "position"; private ListView mListView; private ArrayList&lt;String&gt; mListItems; private int mPosition; public static Fragment newInstance(int position) { SampleListFragment f = new SampleListFragment(); Bundle b = new Bundle(); b.putInt(ARG_POSITION, position); f.setArguments(b); return f; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPosition = getArguments().getInt(ARG_POSITION); mListItems = new ArrayList&lt;String&gt;(); if (mPosition==0){ mListItems.add("Game" ); mListItems.add(".iphone " ); mListItems.add("xxx" ); mListItems.add("yyy" ); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { switch (position){ case 0 : // i want to start new activity if i clicked in game break; case 1 : //start a new activity if i clicked in iphone break; } } private Context getApplicationContext() { // TODO Auto-generated method stub return null; } }); } else if (mPosition==1){ mListItems.add(". item - currnet page:حة 1 " ); } else if (mPosition==2){ mListItems.add(". item - currnet page:حة2 " ); } else if (mPosition==3){ mListItems.add(". item - currnet page:حة 3 " ); } else if (mPosition==4){ mListItems.add(". item - currnet page:حة 4 " );}} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_list, null); mListView = (ListView) v.findViewById(R.id.listView); View placeHolderView = inflater.inflate(R.layout.view_header_placeholder, mListView, false); mListView.addHeaderView(placeHolderView); return v; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setOnScrollListener(this); mListView.setAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), R.layout.list_item, android.R.id.text1, mListItems));} @Override public void adjustScroll(int scrollHeight) { if (scrollHeight == 0 &amp;&amp; mListView.getFirstVisiblePosition() &gt;= 1) { return; } mListView.setSelectionFromTop(1, scrollHeight);} @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mScrollTabHolder != null) mScrollTabHolder.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount, mPosition); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // nothing } } </code></pre>