NavigationView setNavigationItemSelectedListener 此 API 被标记为内部支持库,不应从应用程序访问
NavigationView setNavigationItemSelectedListener this API is marked as internal to the support library and should not be accessed from apps
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工作室报错
"This API is marked as internal for the support library and should not
be accessed from apps"
对于 setNavigationItemSelectedListener
和 setCheckedItem
。
请帮忙。
更新到 Support Library 25.0.1
后也是如此。
这是一个警告,它适用于 NavigationView
的所有 public 方法,但它很烦人,因为 Android Studio 将其标记为错误。
@SuppressWarnings("RestrictedApi")
暂时解决。
编辑
看起来这是 Android Studio 不支持库的问题。
使用 AS 2.3 Canary 3 我没有看到任何警告。
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工作室报错
"This API is marked as internal for the support library and should not be accessed from apps"
对于 setNavigationItemSelectedListener
和 setCheckedItem
。
请帮忙。
更新到 Support Library 25.0.1
后也是如此。
这是一个警告,它适用于 NavigationView
的所有 public 方法,但它很烦人,因为 Android Studio 将其标记为错误。
@SuppressWarnings("RestrictedApi")
暂时解决。
编辑
看起来这是 Android Studio 不支持库的问题。
使用 AS 2.3 Canary 3 我没有看到任何警告。