wood burning stoves*
The moose likes Android and the fly likes How can i put dynamically a Imagebutton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How can i put dynamically a Imagebutton " Watch "How can i put dynamically a Imagebutton " New topic
Author

How can i put dynamically a Imagebutton

Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 250
I have a list of category(every category is a buttonilage) in my application, evrey category have a many product
i would like to get this product of one of this category when i press this category in the same interface
here's my code

the probleme here when i press one button it display here product and when i press another button, it display the previous product and the new product !!
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3934
    
  17

LinearLayout is a ViewGroup. Does the ViewGroup API have any methods which might help you with this? The Android API Reference can be found here: http://developer.android.com/reference/packages.html

Also, why are you using the nested LinearLayouts? I thought we discussed working with GridView and Adapters?


Steve
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 250
I want to change it to the Gird View, it becomes easier right?
I am a beginner in android and this method it seems to be a little difficult at
coding
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39541
    
  27
Maybe you should start with something a bit less involved, then, until you have a firmer grasp of the basics?


Ping & DNS - updated with new look and Ping home screen widget
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 250
No, i want to do this
thank you for your advise
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3934
    
  17

Sarra Sakka wrote:I want to change it to the Gird View, it becomes easier right?
I am a beginner in android and this method it seems to be a little difficult at
coding

Easier is a bit subjective. Using GridView makes the layout easier, because it handles that for you. It makes efficient display easier because it handles recycling views and what not. It generally makes data handling easier, because the data is separate from the display (using the Adapter as the go between). But it adds some layers of complexity - like using the Adapter, which you have to write yourself, and some interaction (example, you can't use Buttons in the GridView, they won't work without a bit of effort. But you can use ImageViews and let the GridView handle clicks.)

In the previous thread where I showed you how ListView and GridView worked, I also gave you some links to the API Guides on how to use them. I suggest you read that so you get a better understanding of how they work and choose if you want to go that route.
Sarra Sakka
Ranch Hand

Joined: Jul 12, 2013
Posts: 250
Ok, thanks
I'll see it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i put dynamically a Imagebutton
 
Similar Threads
Creating multiple tabs :one after another
Put a Linear Layout
Create Buttons at run time
request in SQLite
How to add a textview dynamically in a table row in table layout