I am a beginner of Android apps and am using Eclipse. I have found some larger samples of pulling APIs but I cannot find a simple one to get started with. I simply want to pull from an XML file on the web (by using an API KEY) and throw it in a LinearLayout (Vertical). I can then go from there, anyone know of any? Below is a sample of my XML:
<xmldata>
<Products>
<ProductCode>ITI-GR12</ProductCode>
<ProductName>Granada 9-3/4" Narrow Rim Platter</ProductName>
<ProductPrice>64.4000</ProductPrice>
</Products>
</xmldata>
I am assuming you are looking for mechanisms which help you to parse XML and extract data from it...Voila here is a link to get you started with different ways of doing it...
http://www.ibm.com/developerworks/opensource/library/x-android/
Good luck!
your question is not easy as you will have quite a lot of programming to achieve what you want.
Here are the steps :
read your data using sax
fill a data structure of your own (build a
class, data members will be filled by
previous parsing)
build an activity, use a layout you define to
show all UI fields you think you need
to display your data
fill the content of each view using the data
structure you filled on step 2.
If you are a beginner, I suggest you first understand steps 3 and 4, having fun with UIs, then try to understand how you could download your file, parse it and fill some data class to provide content for the views.
Regards,
Stéphane
Related
All the data my Android app displays is taken from a XML file. I'm using Volley to retrieve the data and SimpleXML to map the XML data to objects using a Volley custom Request: SimpleXmlRequest.
Every time I refresh the content, it reads the whole XML file and creates every single object again and I have the feeling that this is not the best way to do it, cause this file can be quite large. So I have a few questions about that:
Is there a way to "subscribe" to the XML file to retrieve only the
new items added on it, avoiding to read the whole file every time? I know Volley can cache but doesn't help so much here.
Would it be possible to make a SimpleXmlArrayRequest using
SimpleXML framework? Would it help? Cause I really don't want to
parse the file by myself...
If not, would it worth to switch from XML to Json so I could use
JsonArrayRequest or would I have to read the whole file and refresh
every single item anyway? I've never used it before.
Many items from the source file are displayed as a list using
RecyclerView but, again, when I refresh, I have to remove the items
it had before and add them all again as I'm getting all the items at
once and consequently can't use
RecyclerView.notifyDataSetChanged().
I've been reading a lot, even until finding out the RxJava and RxAndroid which seems perfect but it looks like too hard to integrate Volley and SimpleXML on it... so I hope you can help me :)
Thanks!
I always work with Json apart from being very light, with libraries like GSON its fun to work with.
To get only new new data, my practice is to include two fields in the database tables, 1 for isDeleted (boolean) and 1 for lastModified (long epoc time).
The isDeleted field applies only if the data is accessed by multiple users.
I have some sort of simple mobile shopping section inside my app. I get XML or JSON from server and want to put name/description/price/currency/etc to corresponding views. I really don't want to parse all XML myself and prefer to use some syntax like ["products.product.price" -> R.id.priceTextView] to map xml/json data to Android views.
I googled a little bit but failed to find a good way to do this. Do anybody know some lib or maybe Android class doing that?
So I have JSON, I parsed in and it's sitting there. From my code below it looks like I have put everything into an ArrayList but then what? I mean for example I need the "title" of each JSON object to be an onClick on the first page, is that possible?
Essentially my onPostExceute() is empty/not doing much. Eventually I need to separate each object into it's own page via the onlicks I'm mentioning, but I think I can do that by separating the JSONObjects...? guess I'll come to that when I can.
If I want to separate things should I even be using an ArrayList? It's just what I used for a server test I ran with different code.
Would really appreciate some help. Basically stuck at the last hurdle is how I perceive it. Maybe I'm wrong though. The logs see that the JSON is showing up as one big chunk.
Edit: Removed my code, this is more of a theory question. ListView being the best thing to go with.
yes you can make spearate arraylist for them..and can store them in diferent listviews...on google click you can open new listview showing id and link for google ..and same you can do for microsoft and your other trem.And using onItemClick is a gud option,you can easily get the index of item clicked//
I'm really new to developing on Android. I started learning developing due to an application we need to make. I also have a deadline.
So, I wonder if anyone could help this hopeless rookie out :P That'd be so great.
I need the values of the keywords (lag, kamper, mal, poeng, maldiff, status, posisjon, hb, malH, MalB, E, V, U, T, J, kn, id) to be put into a tableview. Not all of them but many.
If someone got a guide or tutorial that a newbie could follow, it would be greatly appreciated.
Or if someone could set it up for me so I could fill in the rest.
I know I'm way over my head with this stuff but if there's any chance I can get it done, I will try.
Here's an URL to a forum I posted the XML in.
http://www.anddev.org/other-coding-problems-f5/parsing-xml-requesting-guide-for-new-beginner-t55538.html
How do I add XML file? Copy-paste doesn't work.
use jaxp library to parse xml. Inthat xpath concept is there. using this we can easily parse xml.
If I got your problem then according to me there is no method to show data in TableView directly while parsing the xml file, you need to parse XML file and store data(say key - value pair or in bean class) and then you need to write code to set your TableView with parsed vales.
I need to get data from an XML file in Android. On the iPhone environment, my code is:
NSURL *thisURL = [[NSURL alloc] initWithString:#"http://www.xxx.com/file.xml"];
NSArray *myArray = [[NSArray alloc] initWithContentsOfURL:providerURL];
myArray is now an array of dictionary items initialized with contents from file.xml.
Is there any way to do this in Android? Can someone point me to doc or sample code?
I'm new to the Android environment and just need some direction.
Thanks,
Kevin
See Working with XML in Android for a variety of methods for dealing with XML. Which method to use depends on how big your XML is, and what you want to do with it. '
I'm not sure how it makes any sense to turn XML into an array, so no, none of the methods do that. If you want something similar to that, use Json instead of XML.
After a bit of research, it appears to me that using the Simple XML Serialization framework is going to be my best bet, especially since I do have a relatively simple XML file to read. The result will be a 'list' class with several 'entry' classes which seems like a viable way to handle this...probably better than having an array of classes as was done in the iPhone app.