I was wondering if it was possible to run an application on Android that will receive XML files during runtime, where these newly received XML files will then be rendered to the screen (will be shown as layout/view/string).
I was thinking that maybe you could add the newly received XML file to your res folder, but I don't think it'll change much since the generated R class will not be updated when the application is already compiled.
I have also thought of implementing my own XML parsing and rendering, but that would pretty much be like rewritting the entire render mechanism of Android.
Need help!
It will then display on screen the XML data using Android rendering (it should render it as if home_layout.xml was in the res folder)
LayoutInflater does not support anything but layout resources. You would need to write your own layout inflation logic from scratch. Given that you create your desired View hierarchy from the XML, the actual rendering would be no different than if the layout had been inflated from a resource.
Related
I am working with a huge xml file(1.3 mb) from server, it takes about 25 seconds to download from server.
I am getting coordinates from the server. I have to draw them on the screen, so is there a way I can lazy load the view?
I am able to download the xml file and store it in the internal memory and parse it using the SAX parser.
Also can I download the xml in chunks and parse them as I go on?
To Elaborate my problem,
1. I need to download and parse an xml file from the server. The file is roughly 1.3 MB
2. It takes about 30 seconds to download and 4 seconds to parse.
3. I am storing it in a local file and parsing it using SAX parser.
4. In this xml file I am getting the drawing points from which I recreate a drawing on a canvas.
So is there any way I can work on the drawing part as the xml file is being downloaded and parsed on the chunk of downloaded file to minimize the delay and parse smaller segments from the server?
I'm not sure what kind of view/data you're talking about (MapView?) but you have to show something while the download and parse operation takes place.
The Android design guide suggests showing a centered ProgressBar, which they refer to as an "Activity circle". After the operation is complete, hide the progress bar and show your view instead (use a FrameLayout to overlap the "waiting" and "ready" views so you can easily switch between them by changing the visibility).
In this example, an activity circle (in Holo Light) is used in the
Gmail application when a message is being loaded because it's not
possible to determine how long it will take to download the email.
When displaying an activity circle, do not include text to communicate
what the app is doing. The moving circle alone provides sufficient
feedback about the delay, and does so in an understated way that
minimizes the impact.
I'm using JFreeChart to generate a dynamic chart depending on the user input. I have a JSP with some textbox and combobox, the user makes the input and submits it, and the Action process it, generating an image of a chart. I need to display this image on the same JSP as before, below the textbox/combobox.
If I use response.setContentType("image/jpeg"); etc... then I get a page with the image alone. I thought of saving the image to a file and then access it with <img >, but I'm not sure that will work (need to save it to WebContent and I may not be able to access it always?).
Is there a way to somehow cache the image and then access it inside the JSP through an <img> or something? Maybe JFreeChart has an easy way to do what I want?
If it matters, I'm also using struts and spring on my webapp.
Thanks in advance.
I've not tried it, but you might look into org.jfree.chart.imagemap and a suitable URL generator from org.jfree.chart.urls. An outline of implementing a PieURLGenerator is illustrated here.
Well, if you generate the image on the server side, you could always just store it in a temp directory using something like a UUID to generate a unique name for it, and concatenating the image file extension on the end of it.
Make sure that the directory the image is generated is accessible on the webserver, and then send the URL path to the image file on the server back to the JSP using ajax (Direct Web Remoting), for display using Javascript.
Just make sure you also have a chron job or service to clear the older files out of the directory now and again.
You should have a servlet that can create the image you want solely from the URL. The URL can then contain an id, which maps back to an object in your program containing raw data in memory. The servlet then generates the image and returns it.
You can then simply set the url of the image in your current web page in Javascript, and it should be loaded.
This is because JSP's are character oriented which do not lend well to binary data so you need to have a servlet do it.
I have just started working with GWT. I was wondering how I can dynamically move widgets on fly (at web page on client browser) for example to move a row of table up and down, or upload a excel file and display its content right away....something like a dashboard I am talking about. Are there any comprehensive tutorial to refer.
Have a look at the gwt-dnd lib:
http://code.google.com/p/gwt-dnd/
GWT is made for doing the kind of things you are describing. To move widgets you can either set their position or dynamically modify their css. To move rows around in a table look at the api of whatever table class you are using. To upload an excel file do a google search for 'gwt upload' and there will be some instructions - but to display the file you will need to convert it (probably to xml). Converting the file on the server will depend on which server you are using - I also have seen a 3rd party widget that will do that for you.
If youre looking for transition effects or animations , than check out gwtquery. Its really similar to jquery and has pretty simple good examples to start with.
I'm writing a bitmap editor. Each document consists of about 3 bitmap layers and documents are, at the moment, saved as a custom file with a .bme extension. These files can be converted to standard jpg/png files by rendering each bitmap on top of one bitmap and saving the latter.
I need some way for the user to be able to select .bme files they've created already. Is there anything in Android that can make this easier for me?
The only option I can see is to write an activity that creates a list view and write a list adapter that looks for .bme files on disk i.e. a copy of the standard "Media Gallery" app that works for my .bme files. The list adapter will either have to generate a thumbnail preview of the image to show to the user or I'll have to package such a preview in the .bme file when they're created.
This is the only option I can think of. I thought I'd ask in case there is more Android friendly way of doing this. For example, can you add custom file support to the "Media Gallery" app?
Is there anything in Android that can make this easier for me?
Nothing built in. If it weren't for the extension filter, you could link to OI File Manager.
This is the only option I can think of.
It seems like a fine, upstanding option.
For example, can you add custom file support to the "Media Gallery" app?
Not that I am aware of, sorry. Besides, that app is not on all phones.
I need to show the first slide of a PowerPoint presentation in my jsf app. It must look something like that:
user upload the .ppt file to jsf app
the app take the first slide and converts it to Flash
user sees the converted slide in the separate (not as part of the another page)
I suppose that I couldn't use any external converters because the user of the system will not have them when he uses our system.
Also I'm thinkinig about Flash, not HTML, because the presentation can be dynamic.
Any ideas? Can I do this task or it's impossible and I need to think in another way (maybe restriction for end users - to save presentation as png, but I think that my boss won't like this decision).
Maybe I need to look at .xslt format, maybe it would help?
suppose that I couldn't use any external converters because the user of the system will not have them when he uses our system.
You can truly use external tools since your Java/JSF code runs at the webserver, not at the webclient (webbrowser). All the webbrowser get is just the Java/JSF-generated HTML/CSS/JS code. Open a page in webbrowser, rightclick and View Source and see it yourself. You just install the external tool at the webserver and execute it there.
To upload a file in JSF, you'll need to grab a 3rd party component library since the standard implementation doesn't have an upload component, for example Tomahawk's t:inputFileUpload or the one of whatever component library you're currently already using.
To convert PPT to Flash, execute the appropriate action using external tool in the managed bean action method and store the Flash file somewhere in the local disk file system of the webserver. You can store it in the public webcontent so that it's directly accessible by URL, but those files will be lost whenever you redeploy the webapp. If this shouldn't happen, then store it outside the public webcontent.
I don't have hands on experience with PPT-Flash converters, so I can't recommend a specific one, but Google learns me that there's pretty a lot of choice. There seems to be a Java solution of iSpring.
To display the Flash file, use the HTML <object> element which points to the URL of the Flash file. If the Flash file is stored outside the public webcontent, then you'll need to create a Servlet which gets an InputStream of the file from the local disk file system and writes it to the OutputStream of the response along a correct set of HTTP headers and then let the URL of the <object> element point to that instead.