Question

How can I go about refreshing a Card after setting the footnote for it?

Basically, there is a footnote already set for the Card when it is initially created:

    private void createCards() {
    mCards = new ArrayList<Card>();
    Card card;
    String[] step;

    for (int i = 0; i < steps.size(); i++) {
        step = steps.get(i);
        card = new Card(this);
        card.setText(step[1]);
        card.setFootnote("Result:");
        mCards.add(card);
    }
}

But when I click the menu option Yes or No for that Card, I set the footnote again to show "Result: YES" or "Result: No":

    switch (item.getItemId()) {
        case 1:
            resultYesNo = true;
            currentCard.setFootnote("Result: YES");
            return true;
        case 2:
            resultYesNo = false;
            currentCard.setFootnote("Result: NO");
            return true;

And it does change the footnote, but I have to scroll three cards left or right then go back to the Card to see the change happen.

I want it the Card to refresh right away after setting the footnote the 2nd time.

Was it helpful?

Solution

If you want to update a card, after setting the new footnote, you have to notify the cardScrollAdapter:

switch (item.getItemId()) {
    case 1:
        resultYesNo = true;
        currentCard.setFootnote("Result: YES");
        adapter.notifyDataSetChanged(); //your cardScrollAdapter
        return true;
    case 2:
        resultYesNo = false;
        currentCard.setFootnote("Result: NO");
        adapter.notifyDataSetChanged(); //your cardScrollAdapter
        return true;
}

Now, the cards should update.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top