Skip to content

Instantly share code, notes, and snippets.

@mjason
Created January 10, 2014 08:04
Show Gist options
  • Save mjason/8348418 to your computer and use it in GitHub Desktop.
Save mjason/8348418 to your computer and use it in GitHub Desktop.
package cn.glassx.ngk.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import com.google.android.glass.widget.CardScrollView;
import java.util.ArrayList;
import java.util.List;
import cn.glassx.ngdk.NBaseCard;
import cn.glassx.ngdk.NCard;
import cn.glassx.ngdk.NCardScrollBaseAdapter;
public class MainActivity extends Activity {
private List<NBaseCard> cards;
private CardScrollView cardScrollView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createCard();
cardScrollView = new CardScrollView(this);
NCardScrollBaseAdapter adapter = new NCardScrollBaseAdapter(cards);
cardScrollView.setAdapter(adapter);
cardScrollView.activate();
setContentView(cardScrollView);
}
private void createCard() {
cards = new ArrayList<NBaseCard>();
NBaseCard card;
card = new NCard(this);
card.setText("helle word");
cards.add(card);
card = new NCard(this);
card.addImage(R.drawable.ic_launcher);
card.setFootnote("akdsjfkjasdf");
cards.add(card);
card = new NBaseCard(this, R.layout.main, null) {
@Override
public View initView(View view) {
TextView textView = (TextView) view.findViewById(R.id.textView);
textView.setText("kasdfkasjdflkajslfkjkasljfdklajsdklf");
return view;
}
};
cards.add(card);
}
@Override
protected void onDestroy() {
super.onDestroy();
cards = null;
cardScrollView = null;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("hello");
menu.add("word");
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment