[android-developers] How to make a listview with only XML and no adapter

2008-12-25 Thread ChisterNordvik

Hi!

On one of my screens I want to have a list with only one item and I
want to declare the item in XML since that's easier than writing a
separate adapter . So i tried doing it without a ListView like in
"Code 1". The problem then is that selection isn't working like in the
listview. I can't select the one "row" inside the linearlayout.

So is there a way to declare the items in the listview directly in the
XML? My screen looks like this:


 


  

And I want the user to be able to select the textviews or the images.
Hope this was understandable :-)

It's somewhat similar to the question asked here:
http://www.mail-archive.com/android-developers@googlegroups.com/msg01647.html

But the answer was "do it in code"... so does the same apply here?

-Christer


Code 1
http://schemas.android.com/apk/res/android";
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_gravity="right"
android:id="@+id/score_parent_layout">








--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Service not able to download network data while in standby

2008-12-14 Thread ChisterNordvik

Hi!

I have a service polling data at regular time intervals and this works
great except when the phone goes into standby. Then the service never
runs the timer thread and it never receives data. How does the SMS/
Email application do this since I get those notifications while in
standby?

When I did a Windows Mobile application this was just the same, and I
had to resort to a third party timer (SDF) to solve this

-Christer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] How to replicate GUI of Android settings menu

2008-12-04 Thread ChisterNordvik

Hi!

I want to make my settings menu look like the one in Android where
they have a heading and a multiline text below the heading for each
listitem. Anyone got the source code for that GUI? :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Parsing RSS feeds, encoding problems

2008-11-30 Thread ChisterNordvik

It's been added:
http://code.google.com/p/android/issues/detail?id=1398

-Christer

On 1 Des, 01:55, "Xavier Mathews" <[EMAIL PROTECTED]> wrote:
> Same Problem Here. Post It In The Issue Tracker!
>
> On 11/30/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Yes, I have also encountered the same problem. Any suggestions?
>
> > On Nov 30, 10:53 pm, ChisterNordvik <[EMAIL PROTECTED]> wrote:
> >> Hi!
>
> >> Does anyone have a workingRSSparser with Android? I tried doing
> >> simple DOM parsing of the XML but the character encoding isn't handled
> >> properly so the norwegian characters aren't displayed. I have tried
> >> everything but when I get the description element I just get the text
> >> until the norwegian character. Any sample code of parsing
> >> internationalRSSfeeds would be very welcome!
>
> >> Here is the feed that I am having problems
> >> with:http://www.dagbladet.no/rss/fotball/
>
> >> -Christer
>
> >> Sample code that I started out with (have tried lots of encoding
> >> tricks to no avail):
>
> >> Feed feed = createFeed(this,
> >>                                         new
> >> java.net.URI("http://www.dagbladet.no/rss/fotball/";));
> >> ...
> >> public Feed createFeed(Context ctx, URI rssurl) {
> >>                 Feed feed = new Feed();
> >>                 try {
> >>                      DocumentBuilder builder =
>
> >>  DocumentBuilderFactory.newInstance().newDocumentBuilder();
> >>                      Document doc =
> >> builder.parse(rssurl.toURL().openStream());
>
> >>                      NodeList nodes = doc.getElementsByTagName("item");
> >>                      for (int i = 0; i < nodes.getLength(); i++) {
> >>                        Element element = (Element) nodes.item(i);
>
> >>                        NodeList title =
> >> element.getElementsByTagName("title");
> >>                        Element line = (Element) title.item(0);
>
> >>                        String feedTitle =
> >> getCharacterDataFromElement(line);
> >>                        String url = getCharacterDataFromElement
> >> (element.getElementsByTagName("link").item(0));
> >>                        Article art = new Article();
> >>                        art.title = feedTitle;
> >>                        art.url = url;
> >>                        art.description = getCharacterDataFromElement
> >> (element.getElementsByTagName("description").item(0));
> >>                        feed.articles.add(art);
>
> >>                      }
> >>                    }
> >>                    catch (Exception e) {
> >>                       e.printStackTrace();
> >>                    }
> >>                    return feed;
> >>         }
> >>         public static String getCharacterDataFromElement(Node e) {
> >>                    Node child = e.getFirstChild();
> >>                    if(child == null)
> >>                            return "?";
> >>                    if (child instanceof CharacterData) {
> >>                      CharacterData cd = (CharacterData) child;
> >>                        return cd.getData();
> >>                      }
> >>                    return "?";
> >>                  }
>
> --
> Xavier A. Mathews
> Student/Browser Specialist/Developer/Web-Master
> Google Group Client Based Tech Support Specialist
> Hazel Crest Illinois
> [EMAIL PROTECTED]@[EMAIL PROTECTED]
> "Fear of a name, only increases fear of the thing itself."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Parsing RSS feeds, encoding problems

2008-11-30 Thread ChisterNordvik

Hi!

Does anyone have a working RSS parser with Android? I tried doing
simple DOM parsing of the XML but the character encoding isn't handled
properly so the norwegian characters aren't displayed. I have tried
everything but when I get the description element I just get the text
until the norwegian character. Any sample code of parsing
international RSS feeds would be very welcome!

Here is the feed that I am having problems with:
http://www.dagbladet.no/rss/fotball/

-Christer

Sample code that I started out with (have tried lots of encoding
tricks to no avail):

Feed feed = createFeed(this,
new 
java.net.URI("http://www.dagbladet.no/rss/fotball/";));
...
public Feed createFeed(Context ctx, URI rssurl) {
Feed feed = new Feed();
try {
 DocumentBuilder builder =
   
DocumentBuilderFactory.newInstance().newDocumentBuilder();
 Document doc = builder.parse(rssurl.toURL().openStream());

 NodeList nodes = doc.getElementsByTagName("item");
 for (int i = 0; i < nodes.getLength(); i++) {
   Element element = (Element) nodes.item(i);

   NodeList title = element.getElementsByTagName("title");
   Element line = (Element) title.item(0);

   String feedTitle = getCharacterDataFromElement(line);
   String url = getCharacterDataFromElement
(element.getElementsByTagName("link").item(0));
   Article art = new Article();
   art.title = feedTitle;
   art.url = url;
   art.description = getCharacterDataFromElement
(element.getElementsByTagName("description").item(0));
   feed.articles.add(art);

 }
   }
   catch (Exception e) {
  e.printStackTrace();
   }
   return feed;
}
public static String getCharacterDataFromElement(Node e) {
   Node child = e.getFirstChild();
   if(child == null)
   return "?";
   if (child instanceof CharacterData) {
 CharacterData cd = (CharacterData) child;
   return cd.getData();
 }
   return "?";
 }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Setting gradient color of TextView creates problems with selection color

2008-11-02 Thread ChisterNordvik

Hi!

I have a ListView with lines of TextViews (standings table for Premier
League).

In the first column I want to have a gradient so I have modified my
code like this:

//Top team should have a nice green color
if(position == 0)
{
toColor = Color.argb(255, 79, 191, 124);
grad = new GradientDrawable(Orientation.TOP_BOTTOM,
new int[]{Color.GREEN, Color.BLACK, Color.GREEN});
col0.setBackgroundDrawable(grad);
}

But the selector is not happy with this because the gradient is at the
top of the selector. I tried painting the selector at the top with
lv.setDrawSelectorOnTop(true);

But I couldn't get that to look any good. I also tried handling the
selectionChange property of the listview and setting background color
there but how can I clear the selection color when the listItem looses
selection? Do I have to loop through every item?

Are there any better ways of doing this?

Really appreciate any answers!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---