Android: User Interface - android

I am working on an android app and I have to Implement the below screen. That screen has two buttons at the top just like we have in tab view, on changing the button 1 is for opening the Picture view and other is to view the videos screen. Below that buttons I have to Implement two listviews for video screen that will each contain one header like one for songs (below that will be a listview of songs) and second header is for films (below that will be a listview of films). And the data for both songs and films is coming from two different services, just like for songs http://mywebsite.com/songs and for films http://mywebsite.com/films. Now I am little bit confused about the UI that there are many alternatives to implement it, but not sure which one will be best for me.
Please give me some ideas about how to implement it. Should I use a Radio group for the above buttons and on State change it should call the respective method, for a view of video and picture. But for each view I will have to make two listviews , just like in the video screen one for songs and other for films. And making two listviews is little bit complex than a single listview. Is there any way to handle it by only one adapter and in that view the same headers should be there. Ad if someone has any good idea then please share it. Any help will be highly appreciated.

You should consider to use fragments for your tab functionslity.
An alternative for two list views could be one expendablelistview. With two groups. You can add multiple types of items to any list view. You just have to overwrite the getitemtype Methode and define the different types you want to display in your listview.

1) hey bro, firstly u hv to create a swap view with a navigation tab functionality on it. check out this link http://developer.android.com/training/implementing-navigation/lateral.html
2) the above example will provide you 2 fragment pages that you can use for picture and videos separately. You can create the layout of every page as you like via using separate fragment with their own layout as you wish.
3) Now in video layout fragment, you can use 2 list views one by one in the linear layout with orientation vertical. Check this link to get idea how to implement your custom list view. http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
4) You have to put the value of Android:weightSum="2" in parent layout( linear layout with orientation vertical) and put Android:layout_height="0dp" & Android:layout_weight="1" in each list view. This will provide equal space for both the list view in single screen for each type of device.

Related

Horizontal Paging Android

I am relatively new to android.
I have to design an Activity that has a 2 * 4 grid.
Each grid item will have an image view and a text view
On swiping left or right the user will move to a different page but the UI will remain the same.
Just the data set to the grid will change.
I want the number of pages to be configurable.
Also I want to reuse the same xml file for UI instead of creating two new xml files for the other 2 pages.
Which is the best possible way and the most efficient way to implement this and any examples on how to do this ? Any help will be appreciated. Thank you
I think you can use ViewPager with Fragment. You can see in this example https://developer.android.com/training/animation/screen-slide.html
You could achieve this with a ViewPager, each page (probably Fragments) containing a RecyclerView with an Adapter..
The fragment code, layout file and adapter implementation would be identical for every page. You just need to pass in the respective data to display to each page.

Design a Grid view with categories and load images on demand in android

I want to create a grid view similar to the image shown below. The category panel
can be scrolled horizontally and has a list of items. When clicked on a category the grid view is loaded dynamically and selected category is underlined/highlighted. Grid also loads images on scroll vertically as well.
Currently, I download a xml with images to a gridview and use Picasso library to load images.
What I want to know is
1) how to add the categorizing to my current implementation?
2) Do I load a single xml with categories and image list first and then load images after or do I keep a xml per category.
3) How do I manage the grid adapter when user clicks on different categories
4) How do I design the category scroll view at top?
Well, after reading the question thoroughly your not asking for a Solution, your asking a Suggestions !!
So, i come up with some approaches to guide you regarding the implementation.
As you mentioned in your question, you have different different categories and each of the category having the grid of images. one main hing is like you can select the category / you can swipe the grid view to change another category in your app.
Why not, these all you can do. Did you used Fragments & ViewPager ?
by combination of Using ViewPager with FragmentPagerAdapter you can achieve the same what your planning.
Here i am explaining you in details >>
your category size is fixed ?
if yes you can make static fragments for those. if it is not fixed in a size / order then you can create PageAdapter with the list of your categories and set that adapter to your view pager in home screen
Now you have a categories, After that you can create a corresponding fragment activity to hold a gridview and based on the page adapter position you can load the categories into the gridview
Here your all fragments having the same gridview, so you easily control it by using vie pager and respective gridview loading and controls you can made in the fragment.
By using this, there is no way of creating such no of xml files & classes as you mentioned in the question. It is a simple and easy way to handle
The big advantage in this approch is like, you no need to bother about the size of categories (as your making as adapter, 35,50,100 that number go's on) it will add the categories to your view pager
fragment loading also you can make a single fragment and re-use the same in all over application as every category having the same grid view .
Here is a sample example to use the fragments with gridviews in a view pager and this
Also you can find a lot of examples in SOF like this..
if you find any difficulty then come with a piece of code/trail what you did and ask in SOF.
Let me if any clarifications required.

Android ListView custom row overlay

I am developing an activity with a ListView in which I need to change the current row by another layout by clicking on the row, and I'm not finding any way to do as much as I look (I take hours searching for possible solutions and I have not seen any reference to this problem). I do not know if this can be done in Android, but if anyone has an idea of ​​how to do this would be appreciated.
Thanks in advance.
PS: The ListView control is normal and just want to replace a layout with a different layout. I'm using the API 15.
Use a ViewSwitcher
http://developer.android.com/reference/android/widget/ViewSwitcher.html
A ViewSwitcher is -
ViewAnimator that switches between two views, and has a factory from
which these views are created. You can either use the factory to
create the views, or add them yourself. A ViewSwitcher can only have
two child views, of which only one is shown at a time.
I suggest merging the two layouts in a single one and hide the second one. In your adapter data you should have a flag or something to indicate which layout to display. When you click a row, toggle that flag for the selected item and notifyDataSetChanged() on the adapter. This will make sure the changed layout remains even if you scroll up and down and the row goes off screen.
A more optimized solution is to have different item types in the adapter.

how to make listview like android market . i.e divided into two columns

I was wondering how to implement the listview like the android market.
in the right hand panel a listview is divided into the two rows. This is very useful because it saves lot of space and user can look at almost double items in the listview at a time. how can I implement this ? any suggestions?
you can use GridView instead of ListView of two columns..
1. GridView
2. GridViewExample
Sample design :
The Android Market also uses the ViewPager to scroll between the pages. Here is an example on how you could implement it.
There is another question that is related to this one.Check the folling link, it might help you:
How to display a two column ListView in Android?
Modify you *.xml file to get what you want.
Good luck!
If you want to do this using listView, then each item (row) in the list view should consist of two views. You can do this using a relative layout (or linear layout) with two items side by side.
You can also implement this using a gridview having two columns.

Image in a custom List Android

I have created a custom adapter to display a list, there is an image that is displayed in each row ( the image is the same for all rows, except using an array i am assigning it different values depending on the position). An xml file defines the relative layout that i am using. My problem is that i can either get the entire row to be clickable or nothing at all, I only want this image to be clickable, instead of the entire row. How would i be able to do this ? i am new to android and am pretty much following different tutorials trying to create my list. Any help would be appreciated.
layout is like this :
TEXT:
[Image]
TEXT:
thats wat a row looks like...getting two texts from two different arrays and shows it, a third array is used to link to the image. I just want this image to be clickable instead of the entire row.
Thanks
Android's list component manages clicks per row. This makes it very difficult to achieve what you want to do. Two solutions come into mind:
1) If your list is never very long you could simply use linear layout and scroll view to build the list. This approach won't work if you fill in the list dynamically and you can't be sure that there won't be a very large number of rows as it would use too much memory in that case.
2) Other option is to use ListView but make your text components and images different view types in list ie. break you row into three.
That can be achieved overriding list adapter's getItemViewType(int)
http://developer.android.com/reference/android/widget/Adapter.html#getItemViewType(int)
In this approach you can make the image rows clickable but the text rows not.

Categories

Resources