I wanna change hardcoded TITLE to resource from strings.xml
How to do it properly?
public static final CharSequence TITLE = "Home";
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return HomeFragment.TITLE;
case 1:
return HistoryFragment.TITLE;
case 2:
return StatisticsFragment.TITLE;
}
return super.getPageTitle(position);
}
}
public static final CharSequence TITLE = R.string.title_home;
You don't need to declare
PUBLIC STATIC FINAL Stringvariable, because strings stored in resource file is unchangeable and can be accessed from anywhere at runtime.Use the following code