Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Showing cards like layout as in Google Keep

I was wondering how to show the snapshot of my notes, checklists, images in the grid view. I have no trouble creating the grid view but creating a preview of it is the challenge I'm facing right now as I need to add different type of views(text, checklist, imageview) to the grid according to their time of creation. Works fine for a single type of view like image or text only.

Or in other words. How do I add the different views dynamically to the GridView Adapter?

All or any help is appreciated.

Thanks.

enter image description here

like image 284
buggydroid Avatar asked Apr 25 '13 09:04

buggydroid


People also ask

Does Google Keep have a widget?

Help with your to-do list. Google Keep widgets can help you manage that seemingly endless to-do list. Choose from two widgets designed to put your favorite Keep functionality on your Home screen, like a tappable to-do list that's front and center on your Android device.

How do I add widgets to Google Keep?

To add the widget on an Android device, tap and hold an empty space on your Android home screen, tap the Widget button, scroll down to the Keep widgets, then pick one to install.


2 Answers

They surely do not use a GridView for google Keep - but probably an Adapter nonetheless.

To use different Views with your Adapter you can use different View types:

  1. Override getViewTypeCount() to return the number of View types you support.
  2. Return the appropriate type in getItemViewType(int position) for this specific item.
  3. Create the correct View in getView(int position, View convertView, ViewGroup parent).

Keep in mind that the rules for recycling, ViewHolder and so on still apply. For multiple types recycling only happens for the correct type.

Marcus Körner shared a gist by Jake Wharton on G+ recently that might be useful.

like image 127
Wolfram Rittmeyer Avatar answered Dec 11 '22 11:12

Wolfram Rittmeyer


More than likely Google is using something similar to GridLayout, if not actually using a GridLayout.

Chances are the layout is also created programmatically to allow for the widgets to be different sizes based on the content that they each display.

like image 29
Gatekeeper Avatar answered Dec 11 '22 09:12

Gatekeeper