Thanks for the reply Jack. No. I am using a TabActivity and I am doing a getTabHost(). Then I am adding the grid view from the Inflated UI to the tab host. Actually If I keep just the grid view inside the xml with out any other layouts or views it works fine.
For example if my example looked like this.. ---------------------------------------- <?xml version="1.0" encoding="utf-8"?> <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"/> ------------------------------------------- Then it works with the code I posted above.. So I am not sure If I need to do a setContentView when I am using a tab host.. any more thoughts .. ? On Aug 13, 11:56 am, Jack Ha <[email protected]> wrote: > 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> > > <GridViewxmlns: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 -~----------~----~----~----~------~----~------~--~---

