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//
Related
I need a little help with an issue in App Inventor 2. The case is that I have a JSON result that is parsed, and then have it stored in a tinyDB tag as a list (storeparseData).
Problem is that, I have this function done as screen initiates, so to have the tinyDB tag populated with that JSON list and then searched for a specific value on user request.
As the app is running and I input a search criteria, I get the following error "The arguments [empty-string] are the wrong number of arguments for GetValue". I suppose that, it finds nothing yet to be stored in the tinyDB tag to search for, cause the JSON data take some time to be fetched and parsed.
Here is what I have done for now for checking if the stored list is in the tinyDB:
Here I check the stored list in tinyDB for an item:
So how can I check if the tinyDB is populated in this tag with the JSON results list, so I can then have it searched? Is this possible in App Inventor 2?
Please someone advise on this issue with a sample code blocks if possible, or a similar tutorial, if there is any. Thank you all in advance for your answers.
This looks very strange... a complicated if then else structure, loads of empty sockets and your comparison if "storeparsedData" = <empty string> always will be false... obviously this does not make sense...
it looks like you are thinking too complicated?
what about this:
As already recommended in my answer to your other question you should learn how to work with lists...
how to work with lists
how to work with list of lists (pdf) by appinventor.org
see also An example of a complex List of Lists
Also doing some more tutorials might help to learn some more basics...
To answer your question "Can you explain why you've chosen to create an empty list there.": if you are working with lists as in the example and you are trying to read a list from TinyDB, then you also have to think about what should happen, if that tag is not available in TinyDB (for example after starting the app the first time). And for lists, in this case an empty list should be returned. Note: the is list empty? block always expects a list. If you set valueIfTagNotThere to an empty string, then you will get a runtime error...
You can use Clock function to delay the time. Firstly, just set the global DelayCountdown to specific number in "when Screen1.Initialize" part. Then, by using "when Clock1.Timer" function, you just need to add another check whether the DelayCountdown is equal to zero before you do another function.
I have a parseobject which consists of many objects, notably an array of consisting of ParseUser pointers.
When an individual clicks a button, the array should remove a certain User.
I don't get how to do this,
I have tried:
mRideEdit.removeAll("Participant", (Collection) childuser);
Where mRideEdit is my ParseClass, Participant is the array consisting of ParseUsers, and childuser is the user I want to remove
Please help,
I've recently faced the same problem.
It originates from how the ParseObjects (including ParseUser) are saved on the server.
If you look at the console, you'll see it is actually an array of strings created from the JSONObject toString method.
The simple answer is - You're using it wrong.
There is no sense in saving objects in such a way (though it's very intuitive).
As you probably noticed - you don't receive them as objects with the getJSONArray method either and have to get them from their objectIds.
The best way to do this is using relations.
If you're set on avoiding relations, what I'd suggest is saving them as strings from the get go (objectId). That way add, addUnique and removeAll will work just fine.
Hope this helps.
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 followed a tutorial located here: http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/ and so far everything worked fine with it. However this only worked nice when there were specific XML tags to go through, such as:
<tag1>
<gettag></gettag>
<gettag2></gettag2>
</tag1>
However my main issue is that I need to get multiple items from within a single tag, like this:
<tag1>
<tag2>text</tag2>
<tag2>text again</tag2>
<tag2>more text</tag2>
</tag1>
I am not able to use the tutorial code to get all of the tag2 items (it stops at the first one). Does anyone know of a good way to grab those "tag2" tags above and spit out the results into a listview?
Any help is appreciated.
Something you may need to do is,
keep a list, If endElement() is tag2, add readtext to list. if endElement is tag1, then create new List and elements.
Check this discussion.
Hi I need a little help with an issue that I have.
I had to build an application which needs to show only a text information and pictures.The content was a lot, that's why instead of creating 200 single activities for very page I create one base activity which content I'm changing everytime depends on which listview item is clicked using putExtra(); and getExtra();. So the problem now is that they want me to create Favourites page, where the users can save some of the information and access them on a single activity.Actually it's really easy to do this using sqlite,but they want from me to finish the application today, within a few hours.My problem is that If i start coding it again and insert all that information in database it will take much more time for me.
So here is a little more explanation :
1.I have base activity with a listview.
2.When user click on listview item I send the content using putExtra in base activity.
So I need to learn how to save the id of listview item or something else and show that content in new Activity. I was thinking of using SharedPreferences but not really sure how to deal with that.
Any suggestions how I can do that...for a few hours.
Thanks in advance!
What kind of content is it? Is it over 200 entries and you don't save them locally?
Just knowing if it's a favorite or not can not be more than one hour job using sqlite. Just keep the id of the content and then a value to see if it's a favorite or not.
Noone will really do that for you since it's obviously your (paid?) job. The fact that you can't do it in time is really not a reason to skip the best option to use.
I would say don't be that optimistic about what you can achieve in which time. Manage your resources better and you will not have that problem.
You can achieve this with sharedpreferences too,but it's not a good idea.
The best way is to do it with database,but it's up to you.