package com.apps4glass.glass.euskalexample;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import com.apps4glass.glass.euskalexample.R;
import com.google.android.glass.app.Card;
import com.google.android.glass.widget.CardScrollAdapter;
import com.google.android.glass.widget.CardScrollView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {

    private List<Card> cards;
    private CardScrollView cardScrollView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        cards = new ArrayList<Card>();

        cards.add(new Card(this).setText("First card"));

        cardScrollView = new CardScrollView(this);
        cardScrollView.setAdapter(new SimpleCardScrollAdapter());
        cardScrollView.activate();
        setContentView(cardScrollView);
    }

    private class SimpleCardScrollAdapter extends CardScrollAdapter {

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

        @Override
        public Object getItem(int i) { return cards.get(i); }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) { return cards.get(i).getView(); }

        @Override
        public int getPosition(Object o) { return cards.indexOf(o); }

    }
}

@@ -67,16 +67,47 @@
 tivity;%0A
+import android.content.Intent;%0A
 import a
@@ -236,16 +236,80 @@
 ewGroup;
+%0Aimport android.widget.AdapterView;%0Aimport android.widget.Toast;
 %0A%0Aimport
@@ -673,16 +673,56 @@
 ollView;
+%0A    private List%3CExampleCase%3E examples;
 %0A%0A    @O
@@ -869,24 +869,139 @@
 ard%3E();%0A
-%0A
        
+ examples = new ArrayList%3CExampleCase%3E();%0A%0A        populateExamples();%0A%0A        for (ExampleCase example : examples)
  cards.a
@@ -1030,20 +1030,25 @@
 ext(
-%22First card%22
+example.getText()
 ));%0A
@@ -1204,47 +1204,610 @@
 ();%0A
-        setContentView(cardScrollView);
+%0A        cardScrollView.setOnItemClickListener( new AdapterView.OnItemClickListener() %7B%0A            @Override%0A            public void onItemClick(AdapterView%3C?%3E adapterView, View view, int selected, long l) %7B%0A                examples.get(selected).onSelected();%0A            %7D%0A        %7D);%0A        setContentView(cardScrollView);%0A    %7D%0A%0A    private void populateExamples() %7B%0A%0A        examples.add(new ExampleCase(%22Test Toast%22) %7B%0A            @Override%0A            public void onSelected() %7B%0A                Toast.makeText(getBaseContext(), getText(), Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D);%0A
 %0A   
@@ -2251,11 +2251,245 @@
 %7D%0A%0A    %7D
+%0A%0A    private abstract class ExampleCase %7B%0A        private String text;%0A%0A        public ExampleCase(String text) %7B this.text = text; %7D%0A%0A        public String getText() %7B return text; %7D%0A%0A        public abstract void onSelected();%0A    %7D
 %0A%7D%0A

Add basic example layout