gpt4 book ai didi

android - 如何修复 "java.lang.NumberFormatException: Invalid double: "?

转载 作者:行者123 更新时间:2023-11-29 18:25:55 24 4
gpt4 key购买 nike

I am trying to get the text from EditText and passing it as double to this Function

Here is my code :

 private MapViewLite mapView;
EditText lat,longs;
Button search;
String getLang,getlong;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lat = findViewById(R.id.lat);
longs = findViewById(R.id.longs);
search = findViewById(R.id.search);
// Get a MapViewLite instance from the layout.
mapView = findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
getLang = lat.getText().toString();
getlong = longs.getText().toString();
search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loadMapScene(getLang,getlong);
}
});
}
private void loadMapScene(String a,String b) {
// Load a scene from the SDK to render the map with a map style.
mapView.getMapScene().loadScene(MapStyle.NORMAL_DAY, new LoadSceneCallback() {
@Override
public void onLoadScene(@Nullable SceneError sceneError) {
if (sceneError == null) {
try {
double aa = new Double(getLang);
double bb = new Double(getlong);

mapView.getCamera().setTarget(new GeoCoordinates(aa, bb));
mapView.getCamera().setZoomLevel(14);
}catch (Exception e){
Log.e("Catch :", e.getMessage());
e.printStackTrace();
}
} else {
Log.e("ERROR ->>> ", "onLoadScene failed: " + sceneError.toString());
}
}
});

After i click on the Button i get the Error as :

W/System.err: java.lang.NumberFormatException: Invalid double: ""

How can this Error be fixed, please reply

最佳答案

你在打电话

getLang = lat.getText().toString();
getlong = longs.getText().toString();

来自 onCreate()

那些值没有设置yes,所以它的文本是"";

将它们移动到 loadMapScene() 方法中

关于android - 如何修复 "java.lang.NumberFormatException: Invalid double: "?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59048288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com