Editable.getText().toString() not working


Last Updated:

  1. rishi360

    rishi360 Member This Topic's Starter

    Joined:
    Jun 5, 2010
    Messages:
    12
    Likes Received:
    1
    I'm trying to create a String and then append it to a URL. But, for some reason, the toString() method doesn't work. From what I can tell, it just gives me a blank String (there IS text in the EditText).

    text = edittext.getText().toString();

    Help? :/
     

    Advertisement
  2. James McMurray

    James McMurray Member

    Joined:
    May 5, 2009
    Messages:
    18
    Likes Received:
    0
    Are you seeing any exceptions?

    What API Level are you building for?

    I just built a quick test Hello World style and the following worked fine:

    Code (Text):
    1. EditText editor = (EditText) findViewById(R.id.EditText01);
    2. Toast.makeText(getBaseContext(), editor.getText().toString(), Toast.LENGTH_LONG)
    3.     .show();
     
  3. rishi360

    rishi360 Member This Topic's Starter

    Joined:
    Jun 5, 2010
    Messages:
    12
    Likes Received:
    1
    I don't believe there are any exceptions. It just returns a blank String, as far as I can tell.

    Ummm I'm not exactly sure >_< But it's Android 1.6.

    Code (Text):
    1.  
    2. text = edittext.getText().toString();
    3. //use text to make finalTextG have "+"
    4.  
    5. googleURL += finalTextG;
    6. guri = Uri.parse(googleURL);
    7. Intent gintent = new Intent(Intent.ACTION_VIEW, guri);
    8. startActivity(gintent);
    9.  
    EDIT: Nvm I got it working.

    Code (Text):
    1.  
    2. String text = edittext.getText().toString();
    3.                 text.replaceAll(" ", "+");
    4.                 googleURL += text;
    5.                 guri = Uri.parse(googleURL);
    6.                 Intent gintent = new Intent(Intent.ACTION_VIEW, guri);
    7.                 startActivity(gintent);
    8.  
     
  4. Boogs

    Boogs Well-Known Member

    Joined:
    Apr 6, 2010
    Messages:
    85
    Likes Received:
    16
    Try this:
    Code (Text):
    1. googleURL += text.replaceAll(" ", "+");
    That line of code should take you to your happy place...
     

Share This Page

Loading...