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

m stuck cant get thru

pliz help

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!
     */

    // Declare mGridView here!

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

        // Set mGridView here!
    }
}

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.

Guy Bridge
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Guy Bridge
Android Development Techdegree Graduate 24,991 Points

Hi,

I guess you first want to declare the GridView;

// Declare mGridView here! GridView mGridView;

Then you need to connect it to the xml // Set mGridView here! mGridView = (GridView) findViewById(R.id.gridView);

Just extend to an ordinary Activity instead of List Activity as is required there and you should be just fine