1. Are you ready for the Galaxy S20? Here is everything we know so far!

get the Double Value from String

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

  1. joevj

    joevj Newbie
    Thread Starter

    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 !!
     



    1. Download the Forums for Android™ app!


      Download

       
  2. JiMMaR

    JiMMaR Android Enthusiast

    you gotta use parse like this

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

    joevj Newbie
    Thread Starter

    Thanks JiMMar. Now it works really nice!
     
Loading...

Share This Page

Loading...