Skip to content

Android coding session 3

February 4, 2011

1. I tried to improve the formatting of the app, I got this exercise working I spent some time trying to adapt this code, but was unsuccessful.
mTitle = new TextView(context);
mTitle.setText(title);
addView(mTitle, new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

mDialogue = new TextView(context);
mDialogue.setText(words);
addView(mDialogue, new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}

2. I couldn’t get this code to do what I wanted, but I did manage to change colours, in table.xml

In MessageList.java I changed this line
new ArrayAdapter(this, R.layout.row,titles);
to
new ArrayAdapter(this, R.layout.table, R.id.description,titles);

This changed the background colour to white and added ‘xxx’

By changing these elements, I now started to understand how to call layout elements from the java file.

3. Next I wanted to stop each item being clickable (a hyperlink), I did this by commenting out the onListItemClick procedure in MessageList.java

4. The app already had 4 menu buttons, I decided to add custom RSS feeds 2 of them and remove the other 2.
I changed the name of the buttons in strings.xml


London 2012 News
BBC London 2012

 

Added a new feedURL in FeedPaserFactory.java

case DOM:
return new DomFeedParser("http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/olympic_games/rss.xml");
case ANDROID_SAX:
return new AndroidSaxFeedParser("http://www.london2012.com/news/news.rss");

Here are the new menu’s in the news app

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: