Search code examples
javaandroidlistviewnavigation-drawer

error: cannot find symbol variable listView


private class DrawerItemClickListener implements ListView.OnItemClickListener {
    @Override
    public void onItemClick(AdapterView parent, View view, int position, long id) {
        String item = (String) listView.getAdapter().getItem(position);
        Toast.makeText(getApplicationContext(),item+"선택",Toast.LENGTH_SHORT).show();
    }
}
}

After creating navigationDrawer, OnItemClick events were added to ListView. But it doesn't work.

Error:(74, 36) error: cannot find symbol variable listView

The above error occurs. Could you tell me what's wrong?


Solution

  • The error says listView is not defined in your code, so there is no reference to this object. try to define it in this class or in the super class