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

Let's convert the ListView below to a GridView! Also change the ID to @+id/gridView

what should i do.Please help.I tried but am getting it wrong.

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!
    }
}

1 Answer

Hello,

You're very close here. You just have an extra " at the end of your xml. Delete it and you should be able to pass this first task. Refer to following comment in the code below to see where to remove the ".

<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>"   <!-- Remove the " on this line here -->

If you need further assistance please let us know and we will try to assist some more.