0

Androidフラグメントのライブラリを使用します。多くの機能を提供するので、cardslib を選択しました。今、フラグメント用に単一の MaterialLargeImageCard を作成しようとしています。

フラグメント xml 内に、カードのレイアウトを追加しました。活用していますnative material largeimage card

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         xmlns:card="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="?android:attr/selectableItemBackground"
         tools:context="com.example.emil.gamerzwiki.NewsFragment">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <it.gmariotti.cardslib.library.view.CardViewNative
        android:id="@+id/carddemo_largeimage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card:card_layout_resourceID="@layout/native_material_largeimage_card"
        style="@style/card_external"
        />


    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/games_list_recyclerView"
        android:divider="@color/gw.dividerColor"
        android:dividerHeight="4dp"
        >
    </android.support.v7.widget.RecyclerView>

</LinearLayout>

私のフラグメント内には、 https://github.com/gabrielemariotti/cardslib/blob/master/doc/MATERIALCARD.md#how-to-build-a-material-card-with-an-に従って次のモデルが設定されています。画像

ArrayList<BaseSupplementalAction> actions = new ArrayList<BaseSupplementalAction>();

        // Set supplemental actions
        TextSupplementalAction t1 = new TextSupplementalAction(getActivity(), R.id.text1);
        t1.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {
            @Override
            public void onClick(Card card, View view) {
                Toast.makeText(getActivity()," Click on Text SHARE ",Toast.LENGTH_SHORT).show();
            }
        });
        actions.add(t1);

        TextSupplementalAction t2 = new TextSupplementalAction(getActivity(), R.id.ic1);
        t2.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {
            @Override
            public void onClick(Card card, View view) {
                Toast.makeText(getActivity()," Click on Text LEARN ",Toast.LENGTH_SHORT).show();
            }
        });
        actions.add(t2);

        //Create a Card, set the title over the image and set the thumbnail
        MaterialLargeImageCard card =
                MaterialLargeImageCard.with(getActivity())
                        .setTextOverImage("Italian Beaches")
                        .setTitle("This is my favorite local beach")
                        .setSubTitle("A wonderful place")
                        .useDrawableId(R.drawable.abc_ab_share_pack_holo_light)
                        .setupSupplementalActions(R.layout.card_native_material_supplemental_cations_large_icon, actions)
                        .build();

        card.setOnClickListener(new Card.OnCardClickListener() {
            @Override
            public void onClick(Card card, View view) {
                Toast.makeText(getActivity()," Click on ActionArea ",Toast.LENGTH_SHORT).show();
            }
        });

アプリを実行すると空のカードが表示されるだけです。モデルがカード ビューに接続されていないようですが、これを接続する方法はありますか? または私は何か間違ったことをしていますか?

助けてくださいありがとう!

4

1 に答える 1