-5

I m try to convert my string value to double, the values i take it from server with web service, here is my code:

private EditText lat;
private EditText lng;

i declare them as text

lat.setText(performance.latitude);
lng.setText(performance.longitude);

and now i declare them in my app screen as well,

@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState) {
    View k = inflater.inflate(R.layout.klient_fragment_kartela, container, false);

lng = (EditText) k.findViewById(R.id.longitude);
lat = (EditText) k.findViewById(R.id.latitude);

return k;

my problem is that i need to declare them as double in the method LatLng, but don't know how, can you help pls. Thnx all

DevilVl
  • 1
  • 2
  • 3

5 Answers5

1

Try this

Double lat=Double.parseDouble(lat.getText().toString());
Double longi=Double.parseDouble(lng.getText().toString());
M D
  • 47,398
  • 9
  • 92
  • 112
0

Using Double.parse() should solve your problem:

Double lat1=Double.parse(yourString) ;
Kao
  • 6,945
  • 7
  • 40
  • 65
koutuk
  • 792
  • 1
  • 7
  • 17
0

you can try this like parsing the string into double :

Double lat = Double.parseDouble(you string value);

balaji koduri
  • 1,403
  • 9
  • 25
Yograj Shinde
  • 819
  • 11
  • 23
0

you can use this

Double.parseDouble(p); 
sakir
  • 3,296
  • 8
  • 32
  • 50
0

You can try this way Double lat = Double.parseDouble("String");

Reena
  • 1,338
  • 1
  • 11
  • 25