Initialize Loader via Navigation Drawer

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Initialize Loader via Navigation Drawer



I want to change the news section using a Navigation Drawer. I want to reinitialize the loader whenever I click on an item in the Navigation Drawer. But I can’t find the right way. I tried to make use of the Activity Lifecycle, but I can't find the right way.


Navigation Drawer


Navigation Drawer





and Here's a portion of the code:



this method is invoked when I click on an item in the Navigation Drawer


Navigation Drawer


public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.headlines: {
section = null;
}
break;
case R.id.world: {
section = "world";
}
break;
case R.id.business: {
section = "business";
}
break;
case R.id.community: {
section = "community";
}
break;
case R.id.sport: {
section = "sport";
}
break;
case R.id.art: {
section = "artanddesign";
}
break;
case R.id.culture: {
section = "culture";
}
break;
default:
section = "culture";
break;
}

item.setChecked(true);
mDrawerLayout.closeDrawers();

return true;
}


@Override
protected void onResume() {

if (isConnected(this)) {
getLoaderManager().initLoader(0, null, this).forceLoad();
} else {
emptyStateView.setText(R.string.no_internet);
loadingIndicator.setVisibility(View.GONE);
}
super.onResume();
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

x9m ib6HVNI0ZeSpPNjzV5LBEnhu4EnrweqTJ4lJ
YjETRh3Z,mPDpvVFiLjH7rMvyuCQ utP1m0 2v5HRGMq1Io3pC34nf,4rN,lAFIdBwn4B2OWmTeG5R,KBXnGHc

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham