Changing views problem.

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Changing views problem.

Postby micke1977 » Sun May 08, 2011 5:51 pm

Hi.
I am having a problem, I am making an application that will start as a ordinary LinearLayout page with a button defined in the xml-file called meny2.xml,

setContentView(R.layout.meny2);
Button kartaButton=(Button)findViewById(R.id.karta);
kartaButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
tillKarta(); //
}

when the button is clicked the tillKarta()-method will change to MapView with locations and a return button to go back to the startmeny.

public void tillKarta()
{
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);

locationListener = new LocationListener()
{
public void onLocationChanged(Location location)
{ // Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

ImageButton ib=(ImageButton)findViewById(R.id.imagebuttontbax);
ib.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
tillMeny();
}


}
);I

}
This far everything is working fine.
The problem is if I am going back to the MapView again after have returned with the imageButton to the menypage the application will go down.

Does anyone know what the problem might be? The MapView and loacation and buttons work exactly as they are supposed to, do I have to clear the mapView before I go back in any way.

Regards Micke
micke1977
Developer
Developer
 
Posts: 25
Joined: Thu Nov 11, 2010 7:46 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests