I have a paragraph of text with a url at the end of it. I have the text and link in the strings.xml. Is there anyway to get it to load a new Activity from the strings.xml file? I'm assuming I'll have to break up the paragraph text and link, but thought I'd check.
strings.xml:
The quick brown fox can be found at: http://thequickbrownfox.com\n more text here
I need to change the hardcoded url "http://thequickbrownfox.com" to load a screen inside my app instead of a page on the web.
strings.xml is purely an abstraction mechanism used for string lookup to facilitate multi language support etc; you cannot use it to load activities or do anything else programatically. It sounds like you are actually talking about parsing the url out of a particular paragraph stored within strings.xml and then depending on what that url is, you invoke a corresponding activity.
If this is the case then you can either parse out the url from the paragraph and respond accordingly.
OR
you can store your paragraph as one item in strings.xml and your url as another item and combine them programmatically in your code.
Either approach can be fine depending on what you are doing.
Related
I have a page I want to scrape with android, and the contents are want are located like this:
body
div#wrapper
div#mainContentArea
div#scheduleModule
div#scheduleDayView
div#scheduleDayViewScroll
div#scheduleItemContainer
div#eventContainer
div#SSPP_o090570*A*
div.eventInfo
p.eventText
span.eventInfoDefault
How can I access the span using jsoup?
If you don't want to be taken out in the streets and whipped for your transgressions, you will split up that block of text there.
Anyway, you want to find the span whose class is eventInfoDefault? Well:
Document site = Jsoup.connect("http://www.example.com");
Element span = site.select("span.eventInfoDefault").first();
//Proceed to do whatever you want with that below.
Source: http://jsoup.org/cookbook/extracting-data/selector-syntax
I have a HTML file and when a user clicks save, a date needs to be added to this html file.
I'm using FileWriter writer = new FileWriter(myFile, true); so it is appended to the end but I have </body></html> so the date is appended to the end of this which I don't want. The date should be appended before those tags. Is there a way to append to a specific place or a more efficient way to solve this problem?
You consider redesigning your code in a way that leaved the layout (HTML) appart from the data (the dates).
You could have a HTML containing the fixed string {{dates_here}} and store the dates in a database or separate file - and then combine them when needed for viewing by constructing an insertable piece of HTML and inserting it with a simple string replace.
With JavaScript, this is not possible, however, I have a solution. Just leave out the <body> and <html> tags, and simply append the tags after appending what's needed. Ever so long ago, it's possible to actually omit those two tags. Try it!
Well, you can keep a DOM in memory of HTML document.
Use JSoup library to make one from a file or String. It will also help you to alter structure in an object oriented way and save it back easily.
Having done some basic tutorials, I started making my first real android app in eclipse. I want this app to check if the text in an EditText matches the text on a PDFpage (this one: http://www.augustinianum.eu/roosterwijzigingen/14062012.pdf (it contains my school's schedule changes)). I've found out how to make the app check if the text in the EditText matches a string (with the method contains()), so now the only thing I need to do is to download all of the text of that PDFpage to a string. But I have no idea how to. Or is there maybe a method which I can check with if a PDFpage contains a certain word without downloading the entire website to a string?
Thank You!
A PDF is not a text-file, it is a binary file. Therefore you should not download the data into a string but into a byte array. Then you must extract the text data from the PDF using some PDF library. In that text you then can search your keyword.
The most interesting part will be to extract the text from the PDF. You may look around this site for other questions which tried the same. Here is a quick search or this.
I have an android app that I want to internationalise.
I have extracted the app strings and deployed them in resource files and all that works fine.
The remaining issue I have is that my app reads a folder structure and actually pulls filenames in as words to use in the app.
I have these filenames/words defined in my xml, but I can't figure out how to dynamically lookup the english language word.
So. here's the scenario.
Filename = hello.png. I want the word "hello" to appear in my app corresponding to the image; I have the word "hello" defined in my strings.xml and the corresponding language files as "hello_file" (i.e. the word "hello" can be accessed by R.string.hello_file). What I think I need to do is take the english word from the filename and do a reverse lookup on the strings.xml file and find the node corresponding to that and then lookup the corresponding word in the strings_xx.xml file for the iso language translations.
But I don't know how to do that...
Perhaps I'm over complicating this? It does not seem an ideal use case for the strings_xx.xml translation facility.
Any other ideas?
Use string array http://developer.android.com/guide/topics/resources/string-resource.html#StringArray
String[] files = getResources().getStringArray(R.array.file_names);
In code you can loop through all values to find which one you need.
can any one know about how to add/insert emotions/smiles to text(which ever i typed in my edit text for my notes). i have little confusion about if i want to add these smiles of type .png in to edit text type of string, is it possible? and also i have to save these input into sqlite database. normally i know to store string data taken from edit text.
but along with that text i want to also add smiles symbols where ever my cursor placed and to be store in sqlite data base. and get it back to read.
so guys any ideas, most welcome!
Try to use java (i.e. android) spannable method to implement smiley (i.e.) images for that. You will surely get it, search in google for "how to add images/smiley with java spannable method in android?" you will get good idea.
Reading your question the first thing I can think of is Mapping each image to a sequence of letters, for example :) is smiley.png etc. Now your database also has these smaller representation However while reading from the database you can convert those special character sequences to appropriate image.
For simplicity in seraching those Strings You can wrap them in some less used characters i.e. [ or { or <.