views:

106

answers:

5

Hello Experts,

I need to create a screen(scrollable) exactly similar to the screenshot shown here . I have no idea regarding the kind of layout patterns that I should resort to or the widgets that I should use.

The data including thumbnail links, is available dynamically.

Experts, kindly help with your valuable suggestions, advices and help.

Looking forward, Regards, Rony

+1  A: 

The view used in your screenshot is most probably a customized ListView. Take a look at that.

A useful source I often recommend is the API Demos project.

I'll quickly list the steps you need to do in order to reach your goal ;)

  • Read Android application fundamentals (if not yet done)
  • Watch the I/O session about ListView or review the according slides.
  • Take a look at Cursors and ListAdapters (and possibly ContentProviders). The Notepad tutorial might be useful. You'll need them in order to map the data on your list
  • Check out how to create a custom list row layout. Basically create another layout xml file representing a single list row item; usually a LinearLayout with horizontal orientation (having a thumbnail, text,... in your specific case).
  • Have fun ;)

What helped me personally is to look at the native Android Contacts app's source code. It has a pretty "complex" list with sections, icons etc. Either download the android source or browse it here.

Juri
I haven't used ListView very much myself, but I remember hearing that it's a tricky thing to get right. I'd recommend checking out http://www.youtube.com/watch?v=wDBM6wVEO70 (Google I/O 2010 - The World of ListView) for some tips.
Marc
Excellent tip, here is the original (http://code.google.com/events/io/2010/sessions/world-of-listview-android.html). That session explains the inner workings and some optimization stuff. You'll find however a lot of resources dealing with the ListView on the web.
Juri
A: 

Hi Juri, Thanks a lot for those links. I have tried all the stuffs mentioned by you prior to posting this query here. And, I guess I am not a newbie in Android (:, for some of these links seemed to be the very fundamentals which were known to me.

The scenario here seems to be pretty tricky for me and I was searching for some valuable help from someone who have done similar stuff.

Any help is appreciated.

Juri, thanks again for your valuable help.

You should create a comment on my post rather than creating a new entry. That's the way Stackoverflow works ;). Btw, I've update my post. Take a look at the Android contacts app. I'm sure that'll help you.
Juri
A: 

This is a hard question to answer without more information.

Personally, I don't like to use ListView. If you can have the data stored in parallel arrays or something like that, I'd just use a for() loop, adding Buttons, TextViews, etc. to the main layout.

Snailer
Hi Snailer,Yes, I have data stored in individual arrays for each row. I have detailed each row below.1) Youtube(Static Name) 2) Youtube Icon (Static) , 2 buttons (Static) 3) Most Viewed (Static Name) 4) Each individual row(with thumbnail) after Most Viewed title - I have the data to be displayed in three rows in a single Json object(including thumbnail url). I can either make each row as separate Array or the data to be displayed in three rows in a Single Array using this single Json object. 5) Points 3,4 applicable for Most discussed, Most Rated(not in screen)
Sorry for double posting it here. I am quite new to SO and I will take care of it next time.
A: 

I have worked a lot on Listviews and looking at your screenshot, I would suggest avoiding the use of listviews if you can. If you always have a constant layout, even if its the layout that you showed there in the screenshot then I would do the layout of each element[unique ones only] in an xml file and add them dynamically as and when required. Although I am not sure how you want your layout to be exactly, so this might not be good if your elements can increase in number.

achie
Except for the data and thumbnails displayed in the three rows in each section(Most Viewed, Most Discussed), rest all data is static.
>>Although I am not sure how you want your layout to be exactly - Exactly as shown in screenshot.
>>this might not be good if your elements can increase in number. - Exactly like the Most viewed section, I would have a Most Discussed and Most Rated section also, with three rows in each section
Since everything is fixed in number and its always three or less, I would suggest not using the list views but making your own custom view. That would also give you a greater control over the structure of the UI.
achie
A: 

Seeing the screenshot, it's very similar to something I've experienced. I initially used a ListView along with an ArrayAdapter, but in the end, it gave me headaches and had me scratching my head all the time. I'm not Android development expert, but this is how I would do it:

<LinearLayout>
     <!-- Used for the non-scrollable header
          Can be a RelativeLayout if you wish -->
</LinearLayout>

<!-- Scrollable items here -->
<ScrollView>
     <!-- Necessary since ScrollView only accepts one child -->
     <LinearLayout>
          <LinearLayout>
               <!-- This will be the container for the items in your list.
                    You can choose to inflate this layout in your code
                    and use addView to add other child Views you want. -->
               <!-- Views you add here will contain the ImageViews, TextViews
                    for the images and text content -->
          <LinearLayout>
     </LinearLayout>

</ScrollView>
Shane Oliver
Hi Shane, Thanks a lot. I tried your suggestion and it helped me very much. But I have few issues remaining. (1) All the contents which I added to each listview is not shown when I run the app (2) Please find the image here - http://www.4shared.com/photo/i6vEwN4V/device_2.html . In that, you can see that, the side portions are clipped off(I have encircled these portions in red) . (3) When I try to take the youtube image and buttons container linear layout outside the scrollview, xml is not permitting me to do so and it gives me errors.
Please find my source code here http://www.4shared.com/file/tyqY-L9z/YouTube.html . Kindly guide me with your valuable suggestions and help.