-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,665
  • 9
  • 93
  • 114
0

Using Double.parse() should solve your problem:

Double lat1=Double.parse(yourString) ;
Kao
  • 7,225
  • 9
  • 41
  • 65
koutuk
  • 832
  • 1
  • 8
  • 17
0

you can try this like parsing the string into double :

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

balaji koduri
  • 1,321
  • 9
  • 25
Yograj Shinde
  • 839
  • 12
  • 23
0

you can use this

Double.parseDouble(p); 
sakir
  • 3,391
  • 8
  • 34
  • 50
0

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

Reena
  • 1,368
  • 1
  • 11
  • 25