How to get tablayout rest api android?
2024-01-13 02:05

How to get rest api shopmenu arraylist get category_name error i will try error this

@Override public CharSequence getPageTitle(List< shopmenu> list, int position) { shopmenu c = list.get(position); return list.get(1).category_name(c.category_name); }

how to get tablayout title name




other answer :

It looks like youre trying to set the title for each tab in a TabLayout using a getPageTitle method. However, there seems to be a mistake in the way you are trying to retrieve the category name. Heres a corrected version of the method:

java@Override public CharSequence getPageTitle(List< shopmenu> list, int position) { shopmenu c = list.get(position); return c.getCategory_name(); }

Assuming shopmenu class has a method named getCategory_name() that returns the category name, the corrected code should work.

Make sure that the shopmenu class has a method like this:

javapublic class shopmenu { // other fields and methods public String getCategory_name() { return category_name; } }

Replace category_name with the actual variable name used in your shopmenu class.

Additionally, ensure that your adapter implements getPageTitle correctly. Heres an example:

javapublic class YourPagerAdapter extends FragmentPagerAdapter { private List< shopmenu> itemList; // constructor and other methods @Override public CharSequence getPageTitle(int position) { return itemList.get(position).getCategory_name(); } }

In this example, YourPagerAdapter is assumed to be a class extending FragmentPagerAdapter, and itemList is the list of shopmenu items.

Make sure to adapt the code according to your specific implementation and variable names. If you continue to face issues, provide more context or specific error messages for further assistance.