UnhandledException321 :
I have initialized a double variable and want to show it in a TextView.
The variable name is underlined in red.
I have tried to parse it to a String, but it did not work.
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);
}
}
noureldien mohamed :
you have to parth this to String by
String.valueOf(currlat);
I hope it work with you .
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=334384&siteId=1