vitas_kek
vitas_kek

Reputation: 41

How to make Gridview with two TextViews?

can you help me make simple Gridview with 2 Textviews, Item is Textview 1, and SubItem is TextView 2..like this:

ITEM 1            ITEM 2

subitem1          subitem2

I have examples with ImageViews but how to accomplish this with two textviews, is there example? Should I use custom adapter or there is simpler way?

Upvotes: 0

Views: 706

Answers (4)

John Kalimeris
John Kalimeris

Reputation: 86

You can try like this: How to create customized grid view with two textview

Instead of this line: String header = first_String_Variable+"\n"+second_String_Variable;

use this: String header=first_String_Variable+" "+second_String_Variable;

and set grid by using Adapter..

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, header);
gridHeader.setAdapter(adapter);

Finally you have only one textview that looks like two textviews.

Upvotes: 0

Wasim Reza
Wasim Reza

Reputation: 136

Just use two TextView in the item of GridView in the custom adapter.

Upvotes: 0

Prasad
Prasad

Reputation: 3552

You can place any content in the Grid item. Just you need to change the list item layout according to your requirements.You can find the example here

Upvotes: 1

Jas
Jas

Reputation: 3212

Simply change the ImageView with TextView in your GridView item layout.

Upvotes: 0

Related Questions