How to refer to an array by Uri in Android? - android

Programming my application would be a lot easier if I could refer to an array by URI, and use that array to inflate a list. Has anyone done this? Thanks in advance!

No, it's not possible to refer to an array using a Uri in the same way that you do using R.array.yourarray.
Technically, just to say the proper answer, you could wrap an object to parse the Uri for you and return the R.array.yourarray for you. Like a Content Provider, for example. But obviously that is just nonsense, there is no reason to create a non standard thing when the standard works just fine.
I don't think there is any scenario that would require a Uri that the standard way doesn't handle just fine.

Related

How to add images in frescoimageviewer

I am trying to use
com.github.stfalcon:frescoimageviewer:0.5.0
to show images from sdcard. Here, is the code which i am using
new ImageViewer.Builder<>(MyImagesActivity.this,
imgs) // what is this?
.setStartPosition(i)
.show();
The problem is I can't figure out what is the second parameter(imgs). The doc suggests that it is a list or String[]. But I don't know what it is. Is there anyone who has used this library. Any suggestion might be highly appreciated.
You can pass Urls or Uris of the images as Objects[] or List.....
for Example...
String[] a={"https://viralsweep.com/blog/wp-content/uploads/2015/02/unsplash.jpg","http://cdn.mos.techradar.com/art/other/Beach-970-80.jpg"};
Fresco.initialize(MainActivity.this);
new ImageViewer.Builder(MainActivity.this, a).setStartPosition(position).show();
This also help you

Using Set operator in content resolver Android

I have to update a Content Provider DB. As per requirement, I only can do that using context.getContentResolver().
Bt I am unable to use SET operator in this method. Can someone help me on this.
Thanks in advance.
Basically you need to create new URI and implement it's raw query in a way to incorporate join condition between the tables.
This SO answer explains in pretty decent way..Have a look!

How to present parsed JSON in readable format to users?

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//

Android - Getting data from XML file on the web

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.

Finding out all about Android Uri class - use and purpose

Does anyone have some helpful links to find out about Android Uri's?
For example, you get a Uri back from a "take a picture" Intent. What does a URI look like and how do you use it. Why are they used instead of filenames or file handles?
The Dev documentation on the Uri class is practically worthless. http://developer.android.com/reference/android/net/Uri.html It is only clear if you already know exactly what it is, and how to use it.
Thanks for any links.
I'd check out the content providers section
http://developer.android.com/guide/topics/providers/content-providers.html
It expalins URI's for the different content providers and how they work.
Read this post it explained what is URI and URL ? Hope it will help to you.http://javapapers.com/servlet/uri-and-url-difference/
This is a list of URIs that can be used in intents.
http://www.openintents.org/en/uris

Categories

Resources