Did you call setContentView() before findViewById()? If not, your
mGrid will most likely be null.

--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.


On Aug 12, 9:52 pm, sai <[email protected]> wrote:
> Hello,
> I am trying to display a bunch of image icons in a grid view, with
> some basic inductive text on the top. This layout is inside a tab
> pane. For some reason my application just Fore closes without any
> stack trace when I do this
>
> Here is my lay out file.. and the corresponding code that uses it in a
> tab.
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
> android:id="@+id/welcomeLayout" android:orientation="vertical">
> <TextView
> android:id="@+id/txtWelcome"
>  text="@string/app_name"  >
> </TextView>
> <GridView xmlns:android="http://schemas.android.com/apk/res/android";
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>     android:padding="10dp"
>     android:id="@+id/welcomeGrid"
>     android:horizontalSpacing="10dp"
>     android:numColumns="auto_fit"
>     android:stretchMode="columnWidth"
>     android:gravity="center"
>     android:columnWidth="120dp" android:verticalSpacing="15dp"/>
>
> </LinearLayout>
>
> -------------------------------------
>
>          TabHost tabhost = getTabHost();
>
>         LayoutInflater.from(this).inflate(R.layout.grid_welcome,
> tabhost.getTabContentView(), true);
>         TabSpec tab1 = tabhost.newTabSpec("MYTAB");
>         tab1.setIndicator("MYTAB");
>         tab1.setContent(R.id.welcomeLayout);
>         tabhost.addTab(tab1);
>         m_Context = this;
>         mGrid = (GridView) findViewById(R.id.welcomeGrid);
>         mGrid.setAdapter(new ImageAdapter(this));
>
> --------------
> Can somebody tell what is wrong with this ? What is so special with
> GridView ?
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to