NavigationView setNavigationItemSelectedListener this API is marked as internal for the support library and should not be accessible from applications

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 gives me an error

"This API is marked as internal to the support library and should not be accessed from applications"

for setNavigationItemSelectedListenerand setCheckedItem.

Help me please.

+4
source share
1 answer

Same thing after upgrading to Support Library 25.0.1.

This is a warning, and it applies to all publicly available methods NavigationView, but it is annoying because Android Studio marks this as errors.

@SuppressWarnings("RestrictedApi") permits this at the moment.


, Android Studio .
AS 2.3 Canary 3 .

+3

Source: https://habr.com/ru/post/1661089/


All Articles