ANDROID SAX Parser issue
Posted
by
Chris Watson
on Stack Overflow
See other posts from Stack Overflow
or by Chris Watson
Published on 2011-02-21T13:39:18Z
Indexed on
2011/02/21
15:25 UTC
Read the original article
Hit count: 163
Since I am new to java programming, I need a bit of help with this. I stuck on this one issue and can't continue until I get this to work.
I am trying to make a string from that includes a preference int. I saved the data and can display the int (just sample code):
SharedPreferences prefs=PreferenceManager
.getDefaultSharedPreferences(this);
list.setText(prefs.getString("list", "22"));
now, I have a xml parser that is pulling a url correctly as a static string:
public static String feedUrl = String.format("http://www.freshpointmarketing.com/iphone/objects/XML/AND.php?ID=%d", 22);
Works great...
now my issue......
I need to have the preference "int" become the variable in the string, thus making it not static.
static SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
static int myVariable = prefs.getInt("list1", 22);
public static String feedUrl = String.format("http://www.freshpointmarketing.com/iphone/objects/XML/AND.php?ID=%d", myVariable);
If I take out all static references, I get an error on this:
private void loadFeed(ParserType type){
try{
FeedParser parser = FeedParserFactory.getParser(type);
long start = System.currentTimeMillis();
messages = parser.parse();
long duration = System.currentTimeMillis() - start;
Log.i("AndroidNews", "Parser duration=" + duration);
String xml = writeXml();
Log.i("AndroidNews", xml);
List<String> titles = new ArrayList<String>(messages.size());
for (Message msg : messages){
titles.add(msg.getTitle());
}
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, R.layout.row,titles);
this.setListAdapter(adapter);
} catch (Throwable t){
Log.e("AndroidNews",t.getMessage(),t);
}
}
thanks
© Stack Overflow or respective owner