Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot print to a text field in android
    primarykey
    data
    text
    <p>Im new to android and i am trying to make a program that outputs the longitude and latitude integers to the screen inside text fields.</p> <p>Ive have two edit text fields: </p> <pre><code>&lt;EditText android:id="@+id/longitudeField" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;EditText android:id="@+id/latitudeField" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="text"/&gt; </code></pre> <p>I know have a java file that runs a class called EmergencyLocation. In this file i set the longitude and latitude and try to output these to the screen via the edit text fields but every time i do this nothing comes up.</p> <pre><code>import android.app.Activity; import android.location.Location; import android.location.LocationListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import android.content.Context; import android.location.LocationManager; import android.location.Criteria; public class EmergencyLocation extends Activity implements LocationListener { private TextView latitudeField; private TextView longitudeField; private LocationManager locationManager; private String provider; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); latitudeField = (TextView) findViewById(R.id.latitudeField); //logitudeField = (TextView) findViewById(R.id.????); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); locationManager.requestLocationUpdates(provider, 0, 0, this); Location location = locationManager.getLastKnownLocation(provider); onLocationChanged(location); } @Override public void onDestroy() { super.onDestroy(); locationManager.removeUpdates(this); } @Override public void onLocationChanged(Location location) { if(location != null) { System.out.println("Provider " + provider + " has been selected."); int lat = (int) (location.getLatitude()); //int lng = (int) (location.getLongitude()); latitudeField.setText(String.valueOf(lat)); //longitudeField.setText(String.valueOf(lng)); } else { latitudeField.setText(String.valueOf("Provider not avaliable")); //the same with long stuff } } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } </code></pre> <p>as i said before im new to android and i think it is something very simple im missing.</p> <p>thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload