Problem with the Grid view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Problem with the Grid view

Postby kitty » Wed Dec 02, 2009 12:15 pm

Hi all,

This is my first post in this forum. I'm trying to display the icons along with the text(icon name) in the Grid view. I've been searching for it from many days but i didn't get it. Can any one help me in this scenario.

Thanx and regards
Kitty
kitty
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Dec 02, 2009 12:00 pm
Location: India

Top

Postby appforce » Wed Dec 02, 2009 5:03 pm

Hi,

Check this demo from SDK:

http://developer.android.com/guide/samp ... Grid1.html

If this doesn't help, give more details.


AppForce developers
appforce
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Mon Nov 23, 2009 8:28 pm

Problem with the Grid view

Postby kitty » Fri Dec 04, 2009 5:40 am

Hi appforce,

Thanks for your quick reply. I've gone through the link that you've sent. That code is displaying the Main menu icons, I need the icon names underneath that icon. I want to display my own icons but not the main menu icons and I need an Onclick listener for each icon that should start another activity. I hope you understand my problem. I will be waiting for your reply.

Thanx and regards
Kitty
kitty
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Dec 02, 2009 12:00 pm
Location: India

Postby appforce » Fri Dec 04, 2009 11:11 am

Hi Kitty,

It's just a matter of proper ListAdapter implementation. To have a label under each icon, make a XML layout representing a single item in the GridView - it should contain an ImageView and a TextView. In adapter's getView use View.inflate instead of new ImageView(). Load the icons in some other way, depending on your needs - they maybe hardcoded or if you want dynamic loading like from the demo, maybe put a common intent-filter in those activities that needs to be listed in the GridView. Use setOnItemClickListener and proper implementation of your adapter's getItem to launch the activities on click.


Android developers
appforce
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Mon Nov 23, 2009 8:28 pm

Gridview

Postby kitty » Sat Dec 05, 2009 2:27 pm

Hi appforce,

I've understood what you are saying. Can you give me the sample code of that implementation. Because i'm new to the Android, i hope you understand my problem.

Thanks
Kitty :)
kitty
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Dec 02, 2009 12:00 pm
Location: India

Postby appforce » Sat Dec 05, 2009 3:28 pm

Hi Kitty,

Here's an Eclipse project demonstrating one way to implement this.

Android developers
Attachments
GridTest.zip
Eclipse project to show starting Activities from labeled icons in GridView
(140.01 KiB) Downloaded 42 times
appforce
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Mon Nov 23, 2009 8:28 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests