• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Create buttons and layout dynamically  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My requirement is creating buttons dynamically.

I want to create buttons dynamically like

Button1  Button2   Button3   Button4

Button5  Button6   Button7   Button8

Button9  Button10  Button11 Button12

Button13 Button14 Button15 Button16


But only first line is displayed.

Button1  Button2  Button3  Button4

remaining buttons are not visible on screen.
Please check the attached screen shot.

My approach is :

Create a parent lay out using XML.

Create a child layout dynamically.
Create four buttons dynamically and add to child layout.
Add child layout to parent layout.

Please find the below code and please help to check what is the exact issue.





MyGame.png
[Thumbnail for MyGame.png]
 
Bartender
Posts: 20742
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that you have to set their "visible" attribute.
 
mohana krishna
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim Holloway,

Thanks for your reply.
I tried setting visibility to buttons and layouts but still the same issue.
Please find the below updated code.

 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!