Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Implementing Designs for Android Customizing a GridView for Friends Converting a ListView to a GridView

Where am i missing it,everything looks perfectly in place to me....

Now switch over to ProductsActivity.java and convert it to use the new GridView. Use the comments in the code as your guide to create and set mGridView in this simplified example.

activity_products.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <GridView
        android:id="@+id/gridView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>
ProductsActivity.java
import android.os.Bundle;
import android.widget.GridView;

// This parent class no longer applies. Switch it to Activity
public class ProductsActivity extends ListActivity {

    /*
     * Some code has been omitted for brevity!
     */

        GridView mGridView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_products);

        mGridView=(GridView)findViewById(R.id.gridView);
    }
}

3 Answers

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Check out the first comment in ProductsActivity.java :)

I don't know how to deal with that comment.That's what got me stuck.How do i go about it.That is my question,sir.

Ben Deitch
Ben Deitch
Treehouse Teacher

Since we're no longer using a ListView we shouldn't be extending ListActivity. Switch it to Activity.

So we just delete list from ListActivity????