cardslib自定义卡具有自定义标头属性

时间:2015-02-07 16:44:42

标签: java android cardslib

我打算创建一个自定义卡片,其中包含更改的字体和从右到左的文本。我试着写一个这样的自定义卡片类

package com.peomtime.tosca.peomtime.Databse;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.peomtime.tosca.peomtime.R;

import it.gmariotti.cardslib.library.internal.Card;
import it.gmariotti.cardslib.library.internal.CardHeader;

/**
 * Created by CrazyVirus on 2015-02-06.
 */
public class PartHeader extends Card{
    private String Title;
    private String ID;
    private String BookID;
    private Context context;
    private CardHeader header;




    public void setBookID(String BookID)
    {
        this.BookID = BookID;
    }
    public String getBookID(){return this.BookID;}

    public void setTitle(String Title)
    {
        this.Title = Title;
        header.setTitle(Title);
        this.addCardHeader(header);
    }
    public String getTitle(){return this.Title;}

    public void setID(String ID)
    {
        this.ID = ID;
    }
    public String getID(){return this.ID;}

    public PartHeader(Context c){
        super(c, R.layout.card_item);
        this.context =c;
        header = new CardHeader(context);

    }
    public PartHeader(Context context, int innerLayout) {
        super(context, innerLayout);
        init();
    }
    /**
     * Init
     */
    private void init(){

        //No Header

        //Set a OnClickListener listener
        setOnClickListener(new OnCardClickListener() {
            @Override
            public void onClick(Card card, View view) {
                Toast.makeText(getContext(), "Click Listener card=", Toast.LENGTH_LONG).show();
            }
        });
    }
    @Override
    public void setupInnerViewElements(ViewGroup parent, View view) {

        //Retrieve elements
        TextView TitleText = (TextView) parent.findViewById(R.id.text);
        TextView mSecondaryTitle = (TextView) parent.findViewById(R.id.textView2);
        //mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_myapps_main_inner_ratingBar);


        if (Title!=null)
            TitleText.setText(this.getCardHeader().getTitle());

       // if (mSecondaryTitle!=null)
            mSecondaryTitle.setText("test");

      //  if (mRatingBar!=null)
        //    mRatingBar.setNumStars(5);
      //  mRatingBar.setMax(5);
      //  mRatingBar.setRating(4.7f);

    }




}

但它根本不会改变卡片的标题。我的错误是什么?我应该改变其他的东西吗?我试图更改CardArrayAdapter中的文本但是它没有做任何标题

0 个答案:

没有答案