I have started Android development recently.
My ambition is to create an application which send an http request to get a list of posts.
For each post (in json), there is a name, a date and the content of the post.
I know how to parse a json file and how to fill objects.
I am curious about what kind of containers I should use. Is a ListView a nice choice?
It depends on the layout structure or some other details you need. I mean maybe your images are located in two or three columns or something like that. Otherwise of course you need to use ListView.
See this: http://developer.android.com/guide/topics/ui/declaring-layout.html#AdapterViews
Related
as part of a university project, i have to build an android app that will contain informations about diseases, the diseases will be listed in a list (alphabetic order), when clicked on a disease you'll be directed to another layout that contains informations about the disease chosen (including text and images).
i'm new to this and i don't know how to approach this app..and for the text should i build a database or directly input the text inside the app or something like that .if you know a tutorial or something that would help please share
Ps: there is almost 60 Diseases and each disease will have a subitems (causes, treatment, clinical signs .)
thanks
First of all, the comments are right. Please be more precise in your question. Ask what specific problem occured, if possible provide code samples, errors and research state. https://stackoverflow.com/questions/how-to-ask
UI Design (List)
there is almost 60 Diseases and each disease will have a subitems
Therefore I would suggest an ExpandableListView.
Check out this code sample: https://www.journaldev.com/9942/android-expandablelistview-example-tutorial
Afterwards if the user clicks on an item, you open another Activity with details
Data Storage
should i build a database or directly input the text inside the app or
something like that
Static approach
As you can think of, putting data directly into views makes it difficult to maintain, but is faster implemented and less difficult.
Implemenation: I would suggest putting the data into res/raw as a .json file. In your code, build a JSONObject out of it and pass it to the ListViewAdapter.
Dynamic approach
You need Internet permission, a webserver and a remote database from where you can query the data.
Implementation: If you have a hosted webserver you probably have PHP and MySQL databases. Create a table, fill it with data and build an API in PHP where you provide the data from the database. If you have a VPS or dedicated server you can use MongoDB which works with JSON out of the box.
My guess
For an university project, use static. Otherwise dynamic of course.
Hope this helps
I am new to Android (but proficient in programming) and I have been reading the Google documentation.
I am trying to build a small app, just to get familiar with Android (not a very fancy app, just for learning app dev).
The app would have an initial activity containing a list of items, and the user can view them (through another activity), edit them (again another activity) or create new ones (again another activity). My concern is how to store this list of items in the phone.
I do not intend (at the moment) for the app to be synced with any external service, so I am happy to store all the data in a file. Typically I would be looking at 200 items of small size, so a text file (maybe XML or JSON) would be enough I think (SQL would probably be overkill here).
My question is: if I have an XML file with all the items, do I need to parse it and load it in memory for every activity?
For example:
the user enters the app to see the list of items -> must load the XML
the user wants to add a new item-> I need to load the XML again to be able to add an XML child
Is this the most natural way of doing this in Android? having to load the same resource over and over in each activity?
Thanks
If you want to reuse files you may use adapter. You can either create custom adapter or use default one. Besides that you may know programming concepts such as Design Patterns. My point is to reuse in android can be done programmatically.
In your for storing data would be better to use SharedPreferences here tutorial to understand idea about it
If you don't want to use SQL to store your data, you can try SharedPreference.
And yes, you have to load all values in everytime you read or write. But don't worry, it won't be hard for mobile phone hardware.
I want to create an android App that getting Arabic news by RSS Feeds.
I want to know if there are any way to dynamically get the Rss feeds and separate them according to its topics?
Thanks for Advance.
There are at least two ways of doing this.
The first way is to look for a source that provide you with different topics, here's an example of what I mean. With those different topics being treated as each individual news feed, you are able to display them separately.
The second way is to not directly display the feed using ListView. You should first, store the news feeds into somewhere for pre-processing, for instance, you can use SQLite. While storing each news, you include a new column for your desired 'grouping' for separation. After that, you can create an adapter that pull news from this source (or SQLite) and display them in your ListView.
Pardon me for only providing you with the concepts, as I don't have a sample code to show you. I hope you understand what I am trying to describe to you.
I'm working on a little Android project in java, I'm using the webapi of spotify to get me so data to play around with.
First thing I notice when visiting: https://developer.spotify.com/technologies/web-api/ is that a developer can choose to use xml or json.
What i would like to do is 'cache' my data so i can do the following:
read one value from the file, or construct an object based on different values
add the object created above to the lisviewadapter
update the listview with the updated adapter
iterate over previous steps until parsing of file is complete
I want to be as quick as possible for my users so that the ui gets updated while parsing and loading the data. For this I sketched 2 use-cases.
add items to the listview until done
show a X amount of items and show a load more button
What file type is more ideal to use for my problem? xml parsing or json parsing?
How can i do this parsing? which tools meet my requirements?
Which use-case seems better to use?
any tips if you have done something like this in the past?
any guidance is appreciated
I don't make any distinction between XML or JSON. To cache data you have two options. Either write the data to a file (will require reparsing of the file to extract the data (unless you create a new file of, for example, CSV data)) or write the required data to a database after parsing. As for updating ListView, that would be up to you based on the number of entries you have.
Android has both XML and JSON parsers built-in. You don't need GSON.
I'd recommend JSON because JSON uses less bandwitch for transfering and google has made an awesome json parser library called GSON.
I am developing an Android Application and since I do not know XML, I have some problems about XML gridview.
In my application, a query is sent to the server and according to server's response i need to list some data. But as I stated, I do not know how to do. As you can guess, data size can differ from query to query, so i need to have an gridview with unfixed size.
Can you help, by sending an example code, or by explaining how can I list data on my application.
Thank you!
See Hello GridView for a tutorial on using a GridView. A GridView has an unfixed size by default.