Android no suitable constructor found for HeaderItem(int,String,<null>)

1k views Asked by At

I'm a bigginer in android i want to create one app for mobile and TV, When i try to build project i see error:

Error:(156, 33) error: no suitable constructor found for HeaderItem(int,String,) constructor HeaderItem.HeaderItem(String) is not applicable (actual and formal argument lists differ in length) constructor HeaderItem.HeaderItem(long,String) is not applicable (actual and formal argument lists differ in length)

In my MainFragment.java the code is like this:

  private void loadRows() {
    List<Movie> list = MovieList.setupMovies();

    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    mCardPresenter = new CardPresenter();

    int i;
    for (i = 0; i < NUM_ROWS; i++) {
        if (i != 0) {
            Collections.shuffle(list);
        }
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter);
        for (int j = 0; j < NUM_COLS; j++) {
            listRowAdapter.add(list.get(j % 5));
        }
        HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null);
        mRowsAdapter.add(new ListRow(header, listRowAdapter));
    }

    HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null);

    GridItemPresenter mGridPresenter = new GridItemPresenter();
    ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter);
    gridRowAdapter.add(getResources().getString(R.string.grid_view));
    gridRowAdapter.add(getString(R.string.error_fragment));
    gridRowAdapter.add(getResources().getString(R.string.personal_settings));
    mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter));

    setAdapter(mRowsAdapter);

}

Please help me

Thanks to all

1

There are 1 answers

0
smoggers On BEST ANSWER

HeaderItem public constructor only takes either one argument (String name) or two arguments (long id, String name). You currently have three. Remove the third argument null.

Refer to Android Developers documentation here.