Android没有为HeaderItem找到合适的构造函数(int,String,<null>)

时间:2015-06-21 20:27:01

标签: java android television

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

}

请帮帮我

感谢所有

1 个答案:

答案 0 :(得分:1)

HeaderItem公共构造函数只接受一个参数(String name)两个参数(long id, String name)。你现在有三个。删除第三个参数null

请参阅Android开发者文档here