Android – navigationview setnavigationitemselectedlistener this API is marked as internal to the support library and should not be accessed from the application

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*Ini UI*/

        mToolbar = (Toolbar) findViewById(t);
        setupToolbar();

        mNavigationRv = (RecyclerView) findViewById(R.id.navigation_rv);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer);
        mNavigationView = (NavigationView) findViewById(R.id.nv);

        mNavigationRv.setLayoutManager(new linearlayoutmanager(this, linearlayoutmanager.HORIZONTAL, false));
        mNavigationAdapter = new NavigationAdapter(new ArrayList<String>(), this, this);
        mNavigationRv.setAdapter(mNavigationAdapter);
        mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 0, 0);
        mNavigationView.setNavigationItemSelectedListener(this);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

Android studio gave me a mistake

For setnavigationitemselectedlistener and setcheckeditem

Please help.

resolvent:

After updating to support library 25.0.1, it is the same here

This is a warning. It applies to all public methods of navigationview, but it is annoying because Android studio marks it as an error

@Suppresswarnings ("restricted API") temporarily solves it

It seems that this is a problem that Android studio does not support libraries. I don't see any warnings when using as 2.3 Canary 3

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>