1. Download our Official Android App: Forums for Android!

Apps Editable.getText().toString() not working

Discussion in 'Android Development' started by rishi360, Jul 22, 2010.

  1. rishi360

    rishi360 Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    11
    Joined:
    Jun 5, 2010

    Jun 5, 2010
    11
    1
    16
    Northern Virginia
    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

    Rank:
    None
    Points:
    15
    Posts:
    18
    Joined:
    May 5, 2009

    May 5, 2009
    18
    0
    15
    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 Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    11
    Joined:
    Jun 5, 2010

    Jun 5, 2010
    11
    1
    16
    Northern Virginia
    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
    Rank:
    None
    Points:
    18
    Posts:
    85
    Joined:
    Apr 6, 2010

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

Share This Page

Loading...