我是Android领域的大佬,我想为手机和电视创建一个应用,
当我尝试构建项目时,我看到错误:

错误:(156,33)错误:没有为HeaderItem(int,String,)找到合适的构造函数
构造函数HeaderItem.HeaderItem(String)不适用
(实际和正式论点列表的长度不同)
构造函数HeaderItem.HeaderItem(long,String)不适用
(实际和正式论点列表的长度不同)

在我的MainFragment.java中,代码是这样的:

  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);

}


请帮我

谢谢大家

最佳答案

HeaderItem公共构造函数仅采用一个参数(String name)或两个参数(long id, String name)。您目前有三个。删除第三个参数null

请参阅Android开发者文档here

07-24 19:25