1. Check out our companion app, Forums for Android! Download from Google Play

get the Double Value from String

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

  1. joevj

    joevj Member
    Thread Starter
    36

    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 Well-Known Member
    53

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

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

    joevj Member
    Thread Starter
    36

    Thanks JiMMar. Now it works really nice!
     

Share This Page

Loading...