可定制的按钮,这是正确的还是有更好的选择?

customizable buttons, It is correct or is there a better option?

我想自定义按钮,以显示 "title0, TITLE1" 等。我想放一些我自己的东西,LocalVideo、listvideo .. 等等。 我发现的唯一解决方案。但我认为那是不正确的。 肯定是不一样的。

代码库存:

                /* CardPresenter */
    HeaderItem cardPresenterHeader = new HeaderItem(1, "CardPresenter");
    CardPresenter cardPresenter = new CardPresenter();
    ArrayObjectAdapter cardRowAdapter = new ArrayObjectAdapter(cardPresenter);

    for(int i=0; i<3; i++) {
        Movie movie = new Movie();
        if(i%3 == 0) {
            movie.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02580.jpg");
        } else if (i%3 == 1) {
            movie.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02630.jpg");
        } else {
            movie.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02529.jpg");
        }
        movie.setTitle("title" + i);
        movie.setStudio("studio" + i);
        cardRowAdapter.add(movie);
    }

    mRowsAdapter.add(new ListRow(cardPresenterHeader, cardRowAdapter));

代码更改:

                /* CardPresenter */
    HeaderItem cardPresenterHeader = new HeaderItem(1, "CardPresenter");
    CardPresenter cardPresenter = new CardPresenter();
    ArrayObjectAdapter cardRowAdapter = new ArrayObjectAdapter(cardPresenter);

 for(int i=0; i<1; i++) {
        Movie movie = new Movie();
        if(i%3 == 0) {
            movie.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02580.jpg");
        }
        movie.setTitle("Videoview");
        movie.setStudio("Video local video");
        cardRowAdapter.add(movie);
    }

    for(int i=0; i<1; i++) {
        Movie movie = new Movie();
        if(i%3 == 0) {
            movie.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02580.jpg");
        }
        movie.setTitle("Listview");
        movie.setStudio("Listview local video");
        cardRowAdapter.add(movie);
    }
    mRowsAdapter.add(new ListRow(cardPresenterHeader, cardRowAdapter));

如果你指的是this site,请问我。

这是你想要的吗?

    /* CardPresenter */
    HeaderItem cardPresenterHeader = new HeaderItem(1, "CardPresenter");
    CardPresenter cardPresenter = new CardPresenter();
    ArrayObjectAdapter cardRowAdapter = new ArrayObjectAdapter(cardPresenter);

    // Create movie1 object
    Movie movie1 = new Movie();
    movie1.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02580.jpg");
    movie1.setTitle("Videoview");
    movie1.setStudio("Video local video");

    // Create movie2 object
    Movie movie2 = new Movie();
    movie2.setCardImageUrl("http://heimkehrend.raindrop.jp/kl-hacker/wp-content/uploads/2014/08/DSC02580.jpg");
    movie2.setTitle("Listview");
    movie2.setStudio("Listview local video");

    // put movie1 and movie2 into cardRowAdapter
    cardRowAdapter.add(movie1);
    cardRowAdapter.add(movie2);

    // show cardRowAdapter in listrow
    mRowsAdapter.add(new ListRow(cardPresenterHeader, cardRowAdapter));