Simmant
Simmant

Reputation: 1513

How to change the no of columns in different rows in Gridview

I am working in an app which requires a grid view with 2 columns. I want to show only one picture in 1st column and then two pictures in all the other columns.

my grid view:

    <GridView


    android:id="@+id/grid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fadingEdge="none"
    android:horizontalSpacing="3dip"
    android:numColumns="2"
    android:verticalSpacing="3dip" />

my current view ![enter image description here][1]

and view i want

![enter image description here][2]

Upvotes: 1

Views: 514

Answers (1)

Pratik Dasa
Pratik Dasa

Reputation: 7439

I suggest you to put that one image in GridView Header, because this kind of stuff will occurs some problems in development and it will become complex. So put that one image in header and remaining are in gridview. Everything will work fine. See header example below:

private View headerView;

headerView = inflater.inflate(R.layout.YOUR HEADER LAYOUT, null, false);//YOUR HEADER LAYOUT is a xml file with the content which you need to display in header, in your case its ImageView only.

ImageView imageview;
imageview = (ImageView) headerView.findViewById(R.id.YOUR IMAGEVIEW NAME);

gridview.addView(headerView);
gridview.setAdapter(YOUR ADAPTER);

Upvotes: 3

Related Questions