0

I am trying to implement a listview of item inside of a Card (com.google.android.glass.widget.CardScrollView). The goal would be to open cardview and display about 10 item in a listview. Given the following activity. Adding the list to any card really. Any help with this is appreciated.

public class Magic extends Activity {
private ArrayList<Card> mlcCards = new ArrayList<Card>();
private ArrayList<String> mlsText = new ArrayList<String>(Arrays.asList("Card 1", "Card 2" , "Card 3"));


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    for (int i = 0; i < mlsText.size(); i++) {
        Card newCard = new Card(this);
        newCard.setImageLayout(Card.ImageLayout.FULL);
        newCard.setText(mlsText.get(i));
        if (i == 0) {
            newCard.setFootnote("My Footer");
        }
        if(i==1)
        {

        }
        mlcCards.add(newCard);
    }

    CardScrollView csvCardsView = new CardScrollView(this);
    csaAdapter cvAdapter = new csaAdapter();
    csvCardsView.setAdapter(cvAdapter);
    csvCardsView.activate();
    setContentView(csvCardsView);
}

private class csaAdapter extends CardScrollAdapter {
    @Override
    public int findIdPosition(Object id) {
        return -1;
    }

    @Override
    public int findItemPosition(Object item) {
        return mlcCards.indexOf(item);
    }

    @Override
    public int getCount() {
        return mlcCards.size();
    }

    @Override
    public Object getItem(int position) {
        return mlcCards.get(position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return mlcCards.get(position).toView();
    }

}

}

thechrisberry
  • 177
  • 1
  • 18
  • And what exactly isn't working? – Ferdau Mar 20 '14 at 09:32
  • Well the question isn't really what is not working, but how to implement. I would like to be able to take newCard and add a ListView to it. Its looking like the only way to accomplish this is to add and activity and start it when the card is tapped. – thechrisberry Mar 20 '14 at 12:21

1 Answers1

0

well I also tryed this before, but with no stable success. Google Glasse is not designed for handling listview.

I made a similar question to yours and the answer is the same as I'm giving you now, use CardScrollView better, I am using them with my app and they work well.

I know it might not be the answer you expected, but hope this helps!

Community
  • 1
  • 1
gkapellmann
  • 313
  • 3
  • 19