我已经初始化一个double类型的变量,并要显示它在一个TextView。
变量名红色下划线。
我曾试图将其解析为字符串,但没有奏效。
public class MainActivity extends AppCompatActivity {
Location currentloc = new Location("currentloc");
double currlat = 0.0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView gpsbox = (TextView) findViewById(R.id.gpsView);
try {
currlat = currentloc.getLatitude();
} catch(Exception e) {
Toast.makeText(this, "Hello, an exception was just thrown but I catched it. " + e.toString(), Toast.LENGTH_SHORT).show();
}
gpsbox.setText(currlat);
setContentView(R.layout.activity_main);
}
}
你必须要PARTH这串
String.valueOf(currlat);
我希望与您合作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句