Thank-you, this makes sense.

What is the best way to wait for an activity to be laid out? Should I
set a listener (if so which listener), use multi-threading, or another
alternative?

The multi-threading option seems redundant to me because the map
rendering is occurring in the UI thread and I just want to know when
its done rendering hence I just want to setup a listener.

yarun

On Oct 9, 8:01 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> This is because at the time code is executed in onCreate(), the first
> layout pass hasn't happened yet. You need to wait for the activity to
> be laid out before you can retrieve these information.
>
>
>
> On Thu, Oct 9, 2008 at 6:28 PM, yarun <[EMAIL PROTECTED]> wrote:
>
> > Hello, in my MapView, getLatitudeSpan is returning 0, and
> > getLongitudeSpan is returning 360,000,000. Similarly, getHeight,
> > getWidth and any other get[Pixel] method is returning 0. How am I
> > improperly setting up my code?
>
> > XML:
> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >    android:id="@+id/map_view_main"
> >    android:layout_width="fill_parent"
> >    android:layout_height="fill_parent">
> >    <com.google.android.maps.MapView
> >        android:id="@+id/map_view"
> >        android:layout_width="fill_parent"
> >        android:layout_height="fill_parent"
> >        android:enabled="true"
> >        android:clickable="true"
> >        android:apiKey="map"
> >        />
> > </LinearLayout>
>
> > Code:
> > public class SampleMap extends MapActivity{
> >        MapView map_view = null;
> >        private String DEBUG_TAG = "MapView";
>
> >        public void onCreate(Bundle icicle){
> >                super.onCreate(icicle);
>
> >                setContentView(R.layout.map_view);
> >                map_view = (MapView) findViewById(R.id.map_view);
>
> >                Log.d(DEBUG_TAG, "bottom: " + map_view.getBottom());
> >                Log.d(DEBUG_TAG, "map Height: " + map_view.getHeight());
> >                Log.d(DEBUG_TAG, "map Width: " + map_view.getWidth());
> >                Log.d(DEBUG_TAG, "latitude span: " +
> > map_view.getLatitudeSpan());
> >                Log.d(DEBUG_TAG, "longtitude span: " +
> > map_view.getLongitudeSpan());
> >        }
> > }
>
> > Aside from getLongitudeSpan, every method called in Log.d returns 0.
>
> --
> Romain Guywww.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to