0

Hi all, I am developing android news app it is possible to increase items to 5 when I have added fifth Menu item. It is giving this exception java.lang.RuntimeException: Unable to start activity ComponentInfo{yodgobekkomilov.edgar.com.worldnews/yodgobekkomilov.edgar.com.worldnews.MainActivity}: java.lang.RuntimeException: List of NavigationPage must contain 4 members.

below my code from MainActivity

public class MainActivity extends BottomBarHolderActivity implements AllJazeeraFragment.OnFragmentInteractionListener, BBCFragment.OnFragmentInteractionListener, CNNFragment.OnFragmentInteractionListener, CBCNewsFragment.OnFragmentInteractionListener {

//    private ApiService apiService;
public static final String url_key = "urlKey";
public ArrayList<Article> articleList = new ArrayList<>();


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

    Article article = new Article(Parcel.obtain());
    article.setUrl(article.getUrl());
    Intent i = new Intent(this, DetailActivity.class);
    i.putExtra("urlKey", article);
// // using the (String name, Parcelable value) overload!
// startActivity(i);

    NavigationPage page1 = new NavigationPage("AllJazeera", ContextCompat.getDrawable(this, R.drawable.alljazeera), AllJazeeraFragment.newInstance());
    NavigationPage page2 = new NavigationPage("BBC", ContextCompat.getDrawable(this, R.drawable.bbc_icon), CNNFragment.newInstance());
    NavigationPage page3 = new NavigationPage("CNN", ContextCompat.getDrawable(this, R.drawable.cnn_icon), AllJazeeraFragment.newInstance());
    NavigationPage page4 = new NavigationPage("CBC", ContextCompat.getDrawable(this, R.drawable.cbc_icon), CBCNewsFragment.newInstance());
    NavigationPage page5 = new NavigationPage("Menu", ContextCompat.getDrawable(this, R.drawable.icon_menu), Menu.newInstance());
    List<NavigationPage> navigationPages = new ArrayList<>();
    navigationPages.add(page1);
    navigationPages.add(page2);
    navigationPages.add(page3);
    navigationPages.add(page4);
    navigationPages.add(page5);
    super.setupBottomBarHolderActivity(navigationPages);
}


public void onClicked() {
    Toast.makeText(this, "Clicked!", Toast.LENGTH_SHORT).show();
}

I am using this library

I know it holds only 4 items but there should other options host fifth items there.

  • I need to add to fifth It is not answer to my question – swedinjon edgarjon Oct 06 '18 at 14:12
  • Above library you add up to five elements..! `See in Feautures section: Add 3 to 5 items (with title, icon & color)`. In your current library items are predefined to max 4 so you can't add new items. [See this output](https://raw.githubusercontent.com/aurelhubert/ahbottomnavigation/master/demo1.gif) – Mohamed Mohaideen AH Oct 06 '18 at 14:14
  • Mohamed assalomu aleykum I have checked your suggestion I think my idea is wrong I will complete the app with four fragment will publish this weekend. I will start from monday using this library. – swedinjon edgarjon Oct 06 '18 at 15:03

0 Answers0