Android : Cannot resolve constructor intent

on Monday, March 30, 2015


Here is a section of my code. I am trying to make a navigation menu that when you click on item 0 it launches the activity MrsClubb. However when I put this into my code it comes up with the error:



Cannot resolve constructor 'Intent(android.widget.AdapterView.OnItemClickListener,java.lang.Class<com....etc>)'


Any ideas how to resolve this?


The double ** shows where in the code the error is.


Here is the section of the code:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer);
mDrawerList = (ListView)findViewById(android.R.id.list);
mDrawerListItems = getResources().getStringArray(R.array.drawer_list);
mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mDrawerListItems));
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
Intent i = new Intent**(this, MrsClubb.class);**
startActivity(i);
}
mDrawerLayout.closeDrawer(mDrawerList);

}
});
mDrawerToggle = new ActionBarDrawerToggle(this,
mDrawerLayout,
toolbar,
R.string.drawer_open,
R.string.drawer_close){
public void onDrawerClosed(View v){
super.onDrawerClosed(v);
invalidateOptionsMenu();
syncState();
}
public void onDrawerOpened(View v){
super.onDrawerOpened(v);
invalidateOptionsMenu();
syncState();
}
};

0 comments:

Post a Comment