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

Apps get the Double Value from String

Discussion in 'Android Development' started by joevj, Nov 1, 2010.

  1. joevj

    joevj Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    18
    Joined:
    Nov 1, 2010

    Hi All,

    I am not an expert in Java and i'm rather new to Android development as well.

    I am unable to extract the double value from a string... here is my code..

    Code (Text):
    1.  
    2.             String str;
    3.             double amount;
    4.            
    5.             final EditText txtAmount = (EditText) findViewById(R.id.entryAmount);
    6.             str = txtAmount.getText().toString();
    7.  
    8.             amount = (double)str;
    9. //            amount =   parseDouble(str);
    10.  
    11.  
    I tried to cast by (double) and tried parseDouble. None of my trials are working.

    Can you help?

    Regards
    Joe


    Is it a wrong location. Now I think I should posted a level below. But not able to remove !!
     

    Advertisement

  2. JiMMaR

    JiMMaR Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    363
    Joined:
    Jun 12, 2010

    Jun 12, 2010
    363
    57
    53
    you gotta use parse like this

    amount = Double.parseDouble(str);
     
    joevj likes this.
  3. joevj

    joevj Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    18
    Joined:
    Nov 1, 2010

    Thanks JiMMar. Now it works really nice!
     

Share This Page

Loading...