Note that there are some explanatory texts on larger screens.

plurals
  1. POStarting an intent from a sliding menu item
    text
    copied!<p>I have this class that defines my sliding menu items and I want to start different intents (not fragments, but activities) when some of them has been clicked.</p> <pre><code>public class RggarbSlidingMenu extends SherlockListFragment{ String[] list_contents = { "My Profile", "My Items", "Messages", "Notifications", "Items Feed", "People Feed", "Places Feed", "Privacy Policy", "Terms of Service", "Settings", "Log Out" }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ return inflater.inflate(R.layout.list, container, false); } @Override public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, list_contents)); } @Override public void onListItemClick(ListView l, View v, int position, long id){ if (position == 0) { Intent signup = new Intent(RggarbSlidingMenu.this, Signup.class); startActivity(signup); } else if (position == 1) { } else if (position == 2) { } else if (position == 3) { } else if (position == 4) { } } } </code></pre> <p>but on the following lines</p> <pre><code>if (position == 0) { Intent signup = new Intent(this, MyProfile.class); startActivity(signup); </code></pre> <p>I get this error:</p> <pre><code>The constructor Intent(RggarbSlidingMenu, Class&lt;Signup&gt;) is undefined </code></pre> <p>How can I start an intent from here?</p> <p><strong>Also, how can I use a selector for items, that is not their position, because this confuses me, I would like to select them by their name instead?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload