GetItem view layout from GridView Android


Ask by : Gabriela Radu November 04, 2012 01:36

Is it possible to get a grid view child item in an activity? The grid is populated and i am trying to get the child view of the gridview to change something in it's layout.

I had overriden the onStart() method:

    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        populateGridView(gridview, beersArray);
        View found = gridview.findViewById((int)gridview.getAdapter().getItemId(1));
        System.out.println("found view: " + found);
    }

But the view is always null. Should i get the grid item view like this? This is my gridview.xml layout that i am trying to access from activity class:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget44"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="201px"
    android:layout_y="165px"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/icon_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/icon_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textSize="10dp"
        android:textColorHighlight="#656565" />

</LinearLayout>

Am i doing this wrong? OnItem click i know what item i am clicking, but i am trying to change the icon on a specific item that i am not clicking. Thank you.

View original question

Answer by : Emil DavtyanNovember 04, 2012 01:02