mapview and setcontentview question

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

mapview and setcontentview question

Postby bdunn13 » Tue Dec 23, 2008 3:47 pm

First of all, I have searched the forums here and the net for a solution to this issue, but no luck.

I have a mapview in a list which is in a tab - all in a xml (main.xml)... Doing a setContentView(R.layout.main); works fine the first time. But when I try and switch back to that view(after doing a setContentView(R.Layout.about) - I get an error saying you can only have one mapview per mapactivity(I think thats the error).

Okay, thats well and good, but how do I cache the view so I can switch back to it? Or is there an easier/better way?

Thanks,
BD
bdunn13
Freshman
Freshman
 
Posts: 4
Joined: Tue Dec 23, 2008 3:37 pm

Top

Postby bdunn13 » Tue Dec 23, 2008 4:10 pm

I would still like to know of a solution - however, for now I am going to get rid of the second view and just make it a dialog.
bdunn13
Freshman
Freshman
 
Posts: 4
Joined: Tue Dec 23, 2008 3:37 pm

Postby dmt » Thu Jan 08, 2009 3:15 am

In your "application" node of your Androidmanifest.xml, create 2 "activity" nodes:

<activity android:name=".MainAppName" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondAppName" android:label="@string/datamanager_name">
</activity>

In your Java code you can switch to the second view (without generating an error) by creating a new Intent object:

// replace main screen with a new screen of second app
Intent i = new Intent(MainAppName.this, SecondAppName.class);
startActivity(i);

And when you're ready to close the second app and return to the first, simply call the "finish()" method from inside the second app. [ I.e. android.app.Activity.finish() ]
User avatar
dmt
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Jan 05, 2009 6:06 am

Postby dmt » Thu Jan 08, 2009 3:19 am

( By the way, you'll have to define your own "android:label..." attribute values instead of using the ones I gave in the example in the AndroidManifest.xml )
User avatar
dmt
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Jan 05, 2009 6:06 am

map

Postby dhaiwat » Thu Feb 12, 2009 11:17 am

i get only blank view not view on map what is problem?
dhaiwat
Developer
Developer
 
Posts: 28
Joined: Tue Feb 10, 2009 6:49 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests