[android-beginners] SAX, XML, and odd results

2009-12-30 Thread Lovedumplingx
So I'm trying to add a list of files to a listview by parsing their
names out of an XML file using the SAX parser.

For some reason though I'm getting a blank data element inserted
before my file name's are processed and I can't figure out why.

My XML looks like:
?xml version=1.0?
fileList
filearch enemy - dead eyes see no future.mp3/file
filetemp.jpg/file
fileBaltimora - Tarzan Boy/file
fileresearch_doc4.pdf/file
/fileList

My XML is well formed and here is the code I use to parse it:
sp.parse(new InputSource(socket.getInputStream()), new DefaultHandler
{
 public void characters(char ch[], int start, int length) throws
SAXException
 {
  super.characters(ch, start, length);
  String xmlCharacterData = new String(ch, start, length);

  files.add(xmlCharacterData.trim());
  }
});

Any thoughts?

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: SAX, XML, and odd results

2009-12-30 Thread Lovedumplingx
So...in combination to what you said and something I read elsewhere
about SAX not handling UNICODE characters I found the issue was
because I had \n used in the creation of my file to make it readable
but alas...SAX was interpretting that as words.  So the issue was with
my XML creation.

Thanks for the thoughts though as I hadn't put 2 and 2 together.

On Dec 30, 2:03 pm, Stefan dahmenstef...@gmx.de wrote:
 On Dec 30, 7:50 pm, Lovedumplingx lovedumpli...@gmail.com wrote:





  So I'm trying to add a list of files to a listview by parsing their
  names out of an XML file using the SAX parser.

  For some reason though I'm getting a blank data element inserted
  before my file name's are processed and I can't figure out why.

  My XML looks like:
  ?xml version=1.0?
  fileList
  filearch enemy - dead eyes see no future.mp3/file
  filetemp.jpg/file
  fileBaltimora - Tarzan Boy/file
  fileresearch_doc4.pdf/file
  /fileList

  My XML is well formed and here is the code I use to parse it:
  sp.parse(new InputSource(socket.getInputStream()), new DefaultHandler
  {
       public void characters(char ch[], int start, int length) throws
  SAXException
       {
            super.characters(ch, start, length);
            String xmlCharacterData = new String(ch, start, length);

            files.add(xmlCharacterData.trim());
        }

  });

 Is this the full source? The characters(...) function gets the names
 between an open and a close tag... perhaps he first find filename
 and he look what text is in this tag (and this is empty!) and after
 that he find the first file tag an there the parser finds the
 names??
 So  i think you need a boolean value like im_in_file_tag.. and if
 the sax parser finds the first file tag you set this boolean value
 to true and if the value is true, you can use your files.add
 (xmlCharacterData.trim());





  Any thoughts?- Hide quoted text -

 - Show quoted text -- Hide quoted text -

 - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Regular Expressions and Eclipse

2009-04-06 Thread Lovedumplingx

Ok...but I thought that by using the \\ then I was using the literal
\ and that it wasn't going to interpret the regex of \d and instead
try to match the string \d

On Apr 3, 7:19 am, A. Dorow andydo...@gmail.com wrote:
 There's two things:

 1. \D refers to everything that is NOT a number digit! \d is what you
 need;
 2. In Java, you must write the String \d, so, as the backslash in a
 String is wrote as two backslashes (\\), your pattern must match THE
 STRING \\d, which means the pattern \d

 so your code will look like
 string.matches(\\d);

 :)

 On Apr 2, 11:39 am, Lovedumplingx lovedumpli...@gmail.com wrote:

  Ok...so I need to do some pattern matching.

  I'm no regular expressions genius but it shouldn't be too hard right?

  so I'm using:

  string.matches();

  in order to evaluate the string.  My problem is that Eclipse doesn't
  seem to like any of my regular expressions I'm putting in there.

  According to the information found here:http://developer.android.com/
  reference/java/util/regex/package-descr.html
  I should be able to use string.matches(\D); to describe a string
  where the first character has to be a number but Eclipse says that \D
  is an Invalid escape sequence (valid ones are \b \t \n \f \r \ \' \
  \ ).

  Any thoughts?  Have I completely messed up how matches is supposed to
  work or am I the victim of some heinous crime?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: How do I set the value of an EditText

2009-03-25 Thread Lovedumplingx

So I see the NullPointer Exception as a good starting point but I'm
still perplexed.

I created a new project just for testing. And I can't get this to
work:

package com.test;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class main extends Activity {
/** Called when the activity is first created. */
EditText justFillIn;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

justFillIn = (EditText) findViewById(R.id.ipText);
justFillIn.setText(charSequence is a string);

setContentView(R.layout.main);
}
}

All I want to do is set the value for that EditText and it's just not
working.

Any help?

On Mar 23, 10:55 am, Lovedumplingx lovedumpli...@gmail.com wrote:
 I get a NullPointer Exception when I use the Debug tool.

 So you're saying that I haven't successfully read the View probably?
 Ok...that's a great starting point.

 On Mar 21, 5:55 am, Tseng tseng.priv...@googlemail.com wrote:

  An error message would be helpful Otherwise it's hard to help you,
  other than guessing what could be the reasons for it.

  Maybe you haven't set the ID correctly, using a wrong ID (which
  doesn't even exist in the XML Layout file) or you're using
  setContentView/setView after you have using findViewById. This could
  throw up a NullPointer Exception when you try to access (because
  findViewById returns 0 if no layout has been set or the View with this
  ID was not found).

  On Mar 20, 9:00 pm, Lovedumplingx lovedumpli...@gmail.com wrote:

   That's what I thought too but I crash the task every time the activity
   that contains this code is started:

  EditTextuserText = (EditText) findViewById(R.id.userText);
   userText.setText(userParam);

   This is the basic way I thought to have the value set but it crashes
   every time.

   On Mar 19, 10:53 pm, Isaac Waller ad...@isaacwaller.com wrote:

A String _is_ a CharSequence. There is no need for a cast.

On Mar 19, 3:35 pm, Will sem...@gmail.com wrote:

 Cast the String to a CharSequence.

 String x = foo;
EditTextET;
 ET.setText((CharSequence) x);

 On Mar 19, 10:43 am, Lovedumplingx lovedumpli...@gmail.com wrote:

  Ok...so I've scoured and scoured and played and fiddled but I can't
  figure it out.

  I want to allow the user to set preferences for an application and I
  want the preferences to be displayed in theEditTextarea if/when they
  come back to change them again.

  In my head I'm thinking I would be able to use setText() but 
  no...that
  takes a CharSequence and I have a string and don't know how to make 
  a
  CharSequence (which according to what I've read is supposed to be a
  read-only thing anyway).

  So...does anyone know how to put text into anEditTextfield without
  relying on the XML?  I really want to do this via application
  preferences.

  Thanks.- Hide quoted text -

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



[android-beginners] Re: How do I set the value of an EditText

2009-03-23 Thread Lovedumplingx

I get a NullPointer Exception when I use the Debug tool.

So you're saying that I haven't successfully read the View probably?
Ok...that's a great starting point.

On Mar 21, 5:55 am, Tseng tseng.priv...@googlemail.com wrote:
 An error message would be helpful Otherwise it's hard to help you,
 other than guessing what could be the reasons for it.

 Maybe you haven't set the ID correctly, using a wrong ID (which
 doesn't even exist in the XML Layout file) or you're using
 setContentView/setView after you have using findViewById. This could
 throw up a NullPointer Exception when you try to access (because
 findViewById returns 0 if no layout has been set or the View with this
 ID was not found).

 On Mar 20, 9:00 pm, Lovedumplingx lovedumpli...@gmail.com wrote:

  That's what I thought too but I crash the task every time the activity
  that contains this code is started:

 EditTextuserText = (EditText) findViewById(R.id.userText);
  userText.setText(userParam);

  This is the basic way I thought to have the value set but it crashes
  every time.

  On Mar 19, 10:53 pm, Isaac Waller ad...@isaacwaller.com wrote:

   A String _is_ a CharSequence. There is no need for a cast.

   On Mar 19, 3:35 pm, Will sem...@gmail.com wrote:

Cast the String to a CharSequence.

String x = foo;
   EditTextET;
ET.setText((CharSequence) x);

On Mar 19, 10:43 am, Lovedumplingx lovedumpli...@gmail.com wrote:

 Ok...so I've scoured and scoured and played and fiddled but I can't
 figure it out.

 I want to allow the user to set preferences for an application and I
 want the preferences to be displayed in theEditTextarea if/when they
 come back to change them again.

 In my head I'm thinking I would be able to use setText() but no...that
 takes a CharSequence and I have a string and don't know how to make a
 CharSequence (which according to what I've read is supposed to be a
 read-only thing anyway).

 So...does anyone know how to put text into anEditTextfield without
 relying on the XML?  I really want to do this via application
 preferences.

 Thanks.- Hide quoted text -

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



[android-beginners] Re: How do I set the value of an EditText

2009-03-20 Thread Lovedumplingx

That's what I thought too but I crash the task every time the activity
that contains this code is started:

EditText userText = (EditText) findViewById(R.id.userText);
userText.setText(userParam);

This is the basic way I thought to have the value set but it crashes
every time.

On Mar 19, 10:53 pm, Isaac Waller ad...@isaacwaller.com wrote:
 A String _is_ a CharSequence. There is no need for a cast.

 On Mar 19, 3:35 pm, Will sem...@gmail.com wrote:

  Cast the String to a CharSequence.

  String x = foo;
 EditTextET;
  ET.setText((CharSequence) x);

  On Mar 19, 10:43 am, Lovedumplingx lovedumpli...@gmail.com wrote:

   Ok...so I've scoured and scoured and played and fiddled but I can't
   figure it out.

   I want to allow the user to set preferences for an application and I
   want the preferences to be displayed in theEditTextarea if/when they
   come back to change them again.

   In my head I'm thinking I would be able to use setText() but no...that
   takes a CharSequence and I have a string and don't know how to make a
   CharSequence (which according to what I've read is supposed to be a
   read-only thing anyway).

   So...does anyone know how to put text into anEditTextfield without
   relying on the XML?  I really want to do this via application
   preferences.

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



[android-beginners] How do I set the value of an EditText

2009-03-19 Thread Lovedumplingx

Ok...so I've scoured and scoured and played and fiddled but I can't
figure it out.

I want to allow the user to set preferences for an application and I
want the preferences to be displayed in the EditText area if/when they
come back to change them again.

In my head I'm thinking I would be able to use setText() but no...that
takes a CharSequence and I have a string and don't know how to make a
CharSequence (which according to what I've read is supposed to be a
read-only thing anyway).

So...does anyone know how to put text into an EditText field without
relying on the XML?  I really want to do this via application
preferences.

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



[android-beginners] Intents and Activities

2009-03-10 Thread Lovedumplingx

Don't know if this went through last time so I'll post again


So I'm still working to get the paradigm down.

Activities are related to screens and everything you want a user to
see needs to be part of an activity.  But what's with the Intent?  Are
all intents tied to an activity?

I thought I had read that Intents were more like events.  If that's
the case cool...but I'm really struggling on where Intents fit into
the whole concept.

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



[android-beginners] Intents and Activities

2009-03-10 Thread Lovedumplingx

Accidentally posted this in the wrong area


So I'm still working to get the paradigm down.

Activities are related to screens and everything you want a user to
see needs to be part of an activity.  But what's with the Intent?  Are
all intents tied to an activity?

I thought I had read that Intents were more like events.  If that's
the case cool...but I'm really struggling on where Intents fit into
the whole concept.

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