Use onCreate() method.
Like
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_test);
map=(MapView)findViewById(R.id.map);
:::::::::::::::
}
I have no issue by calling again.
Hope you can get.
Regards.
On Feb 10, 1:58 pm, Daniel Drozdzewski <[email protected]>
wrote:
> ok, the exception you see means that you can set content view only once;
> Make sure you call setContentView() method only once rather than each
> time you want to bring the activity to foreground.
>
> Daniel
>
>
>
> On Wed, Feb 10, 2010 at 4:44 AM, Sasikumar.S <[email protected]>
> wrote:
> > Thank You Daniel.
> > I'm not calling setContentView() on onCreat().
> > I'm calling setContentView() on some other method.
>
> > According to my program i can't able to set setContentView() in onCreat().
> > How to recreate it , to see one more time.
> > can you pls give suggestion?...
>
> > On Tue, Feb 9, 2010 at 8:14 PM, Daniel Drozdzewski
> > <[email protected]> wrote:
>
> >> ...
> >> Caused by:
> >> java.lang.IllegalStateException: You are only allowed to have a single
> >> MapView in a MapActivity
> >> ...
>
> >> where do you call setContentView() from? It should be called from
> >> onCreate().
>
> >> Daniel
>
> >> On 9 Feb, 13:10, "Sasikumar.S" <[email protected]> wrote:
> >> > Hi,
>
> >> > when i'm using Google map, it is showing nice.
> >> > After i'm coming back & then try to see one more time newly it is
> >> > showing
> >> > error.
>
> >> > The error is below
>
> >> > 02-09 18:36:40.555: ERROR/AndroidRuntime(300): Uncaught handler: thread
> >> > main
> >> > exiting due to uncaught exception
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300):
> >> > android.view.InflateException: Binary XML file line #14: Error inflating
> >> > class <unknown>
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.createView(LayoutInflater.java:513)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.inflate(LayoutInflater.java:407)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.inflate(LayoutInflater.java:320)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.inflate(LayoutInflater.java:276)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
>
> >> > com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.app.Activity.setContentView(Activity.java:1622)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > pack.sample.find.mapview(find.java:253)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > pack.sample.find.onClick(find.java:337)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.View.performClick(View.java:2364)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.View.onTouchEvent(View.java:4179)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.widget.TextView.onTouchEvent(TextView.java:6540)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.View.dispatchTouchEvent(View.java:3709)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
>
> >> > com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
>
> >> > com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.app.Activity.dispatchTouchEvent(Activity.java:2061)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
>
> >> > com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.os.Handler.dispatchMessage(Handler.java:99)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.os.Looper.loop(Looper.java:123)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.app.ActivityThread.main(ActivityThread.java:4363)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > java.lang.reflect.Method.invokeNative(Native Method)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > java.lang.reflect.Method.invoke(Method.java:521)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
>
> >> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > dalvik.system.NativeStart.main(Native Method)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): Caused by:
> >> > java.lang.reflect.InvocationTargetException
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > com.google.android.maps.MapView.<init>(MapView.java:237)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > java.lang.reflect.Constructor.constructNative(Native Method)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > java.lang.reflect.Constructor.newInstance(Constructor.java:446)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > android.view.LayoutInflater.createView(LayoutInflater.java:500)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): ... 31 more
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): Caused by:
> >> > java.lang.IllegalStateException: You are only allowed to have a single
> >> > MapView in a MapActivity
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > com.google.android.maps.MapActivity.setupMapView(MapActivity.java:180)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > com.google.android.maps.MapView.<init>(MapView.java:279)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): at
> >> > com.google.android.maps.MapView.<init>(MapView.java:254)
> >> > 02-09 18:36:40.694: ERROR/AndroidRuntime(300): ... 35 more
>
> >> > can any one tell about these?..
>
> >> > --
> >> > Thanks & Regards
> >> > Sasikumar.S
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Android Developers" group.
> >> To post to this group, send email to [email protected]
> >> To unsubscribe from this group, send email to
> >> [email protected]
> >> For more options, visit this group at
> >>http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Thanks & Regards
> > Sasikumar.S
>
> --
> Daniel Drozdzewski
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en