The page layout is like:
An header image first
a table or list with one record each line
for each record, it has an image and 2 text view
how can I design this layout and populate the data dynamically, e.g. via web download or an data file(xml/text format)?
I can't figure out how the binding works and should I use a table layout with table row or just list view with some customizations?
Actually, this is going to be a broad question because you are asking about to fetch data from web and also need to customize the listview to display data.
To fetch data from Web: You haven't mentioned whether it is SOAP or RESTful webservice? Also what you will receive in response i.e. XML or JSON? For best, i would suggest RESTful with JSON.
To customize ListView: I can give you answer for customizing ListView, for that you can create a custom adapter class by extending BaseAdapter, implement the onView() method with inflation of custom row layout file (1 ImageView + 2 TextViews), check this: Android custom adapter for ListView
The page layout is... it has an image and 2 text view.
Elaborating on jitendra's answer: Yes, a ListView seems ideal for this set up. A TableView is doable, but is really more ideal for a rows/columns structure and that does not sound like what you need.
How can I design this layout ... ?
You would use the android XML to name and style the elements. The best practice is to make a layout file for the screen containing the list itself. Make a second layout file to house a generic record. In other words, you typically design the record separately from the list and its containers. There are several great tutorial on Layouts on the Android Developer's website.
How can I... populate the data dynamically?
There are two parts to this question. First, in code you will need an Adapter of some kind to convert the Data to the actual Views. The ListView will be linked to the Adapter. The Adapter will inflate the Layout XML that you create for the Record. Different Adapters have different guidelines for customizing the Views. As mentioned by Paresh, a BaseAdapter is a great class, but you really should look at the different Adapters provided and see if they already meet your need.
Second, to get the data...1) from the web depends a lot on your web server and how it distributes data. Without more information, you are unlikely to get any solid answers. We can only make recommendations. 2) If you are going via a data file, things change considerably. You can make an Array of objects from a custom Class designed around your data. If you need Sorting, a Tree might be better. If each record has a unique key, a Set or List might do you well. Based on your question, I find myself assuming that you are unfamiliar with Android development, so I would recommend a datafile loaded into an Array with an ArrayAdapter. This will at least help you get a little more familiar with your own project and how it relates to the Android environment.
I can't figure out how the binding works
Unfortunately, it depends on your View and its Adapter. A CursorAdapter does most of its data binding in the bindView() method of the Adapter, but inflates the View in the getView() method. A BaseAdapter does this in the onView() method. If you need to get more familiar with Adapters and their capabilities, read the Android Developer Resources. They have great samples and code. Also, do a search there for "custom adapter" and you will be linked to a ton of other tutorials.
At this point, I recommend strongly, two actions for you. 1) Make a few decisions. Either you get the data from the web or a data file. If you want to do the other later, great. Get a handle on one, that way we can help you more effectively. 2) Use both Google and Android Developer Resources search functionality with the phrases that define your project. If you add the word tutorial or example, you'll be sure to find plenty to help you make those decisions so that we can tailor a solution that meets your needs.
Hope this helps!
FuzzicalLogic
According to your requirements ListView would be good, and you would need to use adapter to bind data with view.
Please read about listview and adapter to implement these.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="#drawable/img_list_background_repeater"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/empty_category"/>
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
No one will give you all java class and xml both.
You frame a xml. Then using adapter try to implent data to the list view.
If then you have any problem, provide your code. Then that can be solved.
Related
I just recently started programming on android and my basic ListViews no longer work for the data I need to show so I'm trying to use the TableView library by evrencoskun (https://github.com/evrencoskun/TableView#documentation).
The problem is I'm not quite following the documentation of how to implement it.
The documentation shows how to create a "custom adapter", "date models" and "Layouts" but I don't know if creating all of those is mandatory for my TableView to work (also I don't get where should I put the "date models") and I have no idea of how to link them up for my ListView to work.
I was also considering using ISchwarz23 ListView library which is supposed to have all the same features but payment for a license is needed so that's a big no no no.
I just improved the documentation for TableView, so I might be able to help.
Custom Adapter is Mandatory. (Much like it is on a more complicated Listview)
Data Models, this is sort of Mandatory BUT depending on your data and as long as you don't want to filter or sort your data then there is a shortcut to not use these. (I have an example that does not use data models as it displays just text Strings)
e.g. In the below Listview Adapter Creation (the Bold highlighted String Object is your single Data Model Type)
ArrayAdapter adapter = new ArrayAdapter<String>(this,
R.layout.activity_listview, dataArray);
Layouts at least one is Mandatory for a very basic layout but 3/4 layouts are required to have a reasonable looking table (Row Header, Column Header, Cells and optionally Corner)
Your data models are just POJO classes, so you can place them anywhere you want in your projects java source directories. But for better structure you might want to place them in there own sub package.
As for
I have no idea of how to link them up for my ListView to work.
This does not link to a Listview widget, it could replace a ListView widget but more commonly replaces GridLayout, TableLayout or the Grid Layout Managers of a RecyclerView widget.
The two sample Apps give you a good basis for your code.
I would get familiar with RecyclerViews first as a step up from ListViews (as this is really just a complicated RecyclerView)
If you are still struggling then ask another question with details of what data you have and how you want it laid out in the table cells.
How can I display information in the following format? What controls should I use, listView or RecycleView?
Note that the question isn't about this particular activity and how to use it. It's about how to show the information in the same format and how to create the layout for it.
That is a ListView. You would just need a ListAdapter/ArrayAdapter to fill it and that's about it.
You can make exactly the same thing using the layout simple_expandable_list_item_2 in the SimpleAdapter of a ListAdapter (here is how you do it : Displaying kind of static data in ListView)
RecyclerView is of course much better in terms of performance and flexibility. However, ListView is enough in many cases like this one.
Good Morning All,
I am creating an application to display List of applications with their data usage.
I want my list to look similar to Traffic Counter Pro on android Market
I have also added the print-screen on my box.net as SOF does allow me to upload image
So Can someone direct me how to create ListView like this?
My second Question related to this how to create a tab style Activity.
Two examples that helped me a lot:
http://www.codemobiles.com/forum/viewtopic.php?t=876
and
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
i hope they are usefull to you.
You have to use custom ListView to embed images and format texts as given in the listview.
check out this example or this example or this example or even this example that gives you good understanding on listviews.
Good luck.
This is ListView which items consist of 4 Views objects, look through the tutorial of how to create ListViews and through the tutorial of how to create TabActivitys. And also use links suggested by #parag.
If you observe the screen shot carefully you can identify that group of these fields are available as list item.
They are
Application Icon
Application Name
Data Uploaded
Data Downloaded
Total Data Usage
So you have to create a layout with these fields as children with appropriate position and Use this custom layout as child layout for ListView.
I hope it may help you.
I've been asked to make an app that has a very VERY long data input form (we're talking around 50 fields here!). Thats a design constraint and there is absolutely no way for me to work around that.
What I'm trying to do is to display the form in a way thats easier on the user. My idea was to break the form into sections and somehow use an expandable list view to display the form. The list group would be the section name and the list items would be the input forms.
My problem is that since the form can contain different types of input fields (checkboxes, radio buttons, textfields etc) and since I'm new to android programming, I dont really know how to do this. All the online tutorials I can find are about simple uniform expandable lists. Can someone suggest me a good tutorial or an alternative to my idea?
I would look into using ExpandableListView as is, but create your own xml layout file for each list 'child' row, putting the field name and then a text input field for the value into it.
Have alook at this page where the author shows how you can put a 'checkbox' next to each list items row:
http://mylifewithandroid.blogspot.com/2010/12/expandable-list-and-checkboxes.html
You have to use child layout view for achiving this.
follow below link and find the code,Inflating only one text view but u can inflate the complete layout(I personally used that thing in my code).
Expandable list view
What you're going to need to do is extend your BaseExpandableListAdapter and customize it to display all the various layout options. Specifically, it's going to be the getChildView() method that you'll have to do the most work in. Do some searches for customizing or extending the BaseExpandableListAdapter and you should find plenty to go by.
Also, take a look at the example from the SDK:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList1.html
Edit: Link not available
I've been trying to find a tutorial of how to create a ListView that get its data from a server dynamically as it's scrolled. I have not been able to find complete documents of how to do this. Only small examples or ListView tutorials that deals with set arrays. This has left me where I don't know where to start building the ListView code.
I have some code that gets data from the server. I also do have all the layouts and basic Activity code.
How/what do ListView do to get one more rows as it is scrolled?
And when I need to have different row layouts. How do ListView handles this?
Is there a complete tutorial that deals with ListView and getting data from a server?
How/what do ListView do to get one more rows as it is scrolled?
There is nothing built into Android for this. You could use my EndlessAdapter, either directly or as an idea of how to accomplish similar ends in your own code.
And when I need to have different row layouts. How do ListView handles this?
You need to implement an appropriate ListAdapter, one that has proper implementations of getViewTypeCount() and getItemViewType().
Is there a complete tutorial that deals with ListView and getting data from a server?
Along with your other two bullets? Probably not. Your requirements are individually uncommon and are even less common in conjunction.