I'm using a CardScrollView
to present a stack of content in an immersion app and I don't want to use the standard Card
as I'd like more control of the layout.
I have an xml layout file that defines the layout I want but I'm having trouble figuring out how to create a local instance of this layout in the code so that I can get/set its components and add them to my card scroll adapter's list.
Has anyone done this, or know where I could find an example or tutorial or something?
Thanks!
Here's the code I've tried so far (its in the onCreate method of an Activity)
setContentView(R.layout.activity_menu_top);
viewCards = new ArrayList<RelativeLayout>();
TextView tv;
RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_menutop);
tv = (TextView) layout.findViewById(R.id.textSectionTitle);
tv.setText("Appetizers");
tv = (TextView) layout.findViewById(R.id.textPreviousItem);
tv.setText("");
tv = (TextView) layout.findViewById(R.id.textNextItem);
tv.setText("Entress >");
viewCards.add(layout);
//repeat that last chunk a bunch of times
menuCSV = new CardScrollView(this);
menuCSV.setOnItemClickListener(this);
adapter = new MenuCardScrollAdapter();
menuCSV.setAdapter(adapter);
menuCSV.activate();
setContentView(menuCSV);
The 'TextView' ids I'm referencing are child views of the 'RelativeLayout' as I've defined in my layout xml. I've tried a few variations on the code above and I'm having trouble figuring out the correct way to get and set these elements and then stick them in a List as a single object for the 'CardScrollAdapter'. I'm sure this is supposed to be pretty straightforward but I can't figure out what I'm missing.
Thanks again!