views:

393

answers:

1

My View doesn't use an XML layout, I just reference a View subclass defined in the Action class. The app consists of an empty canvas that the user can create/interact with various 2D objects. That's the easy part, but I want an onscreen widget to appear on the right side of the screen that allows the user to select various objects to create. Because there can be several objects the widget will just display the two or three most recently used objects, and expand to present all possible objects when an expansion button is clicked.

Due to the highly specific nature of this widget I was thinking I needed to write my own custom widget, but was unsure how I could integrate this into my existing view. Is it possible to display a small widget inline in this manner?

The other option I am considering is using Drawable to create this widget on the Canvas, detecting mouseclicks, and handling the action that way. Doesn't sound like that is the right way to do it within the Android architecture, however.

A: 

I'm not sure why you would need a custom widget. What is "highly specific" about your widget? It sounds like you just want a number of icons for the user to select.

To accomplish that, you could use a ListView whose contents are ImageButtons. You can edit the contents of the ListView depending on if its in the expanded state or not (does it have 3 items or 10).

Mayra
OK- but what I'm wondering about specifically is if I could mix this view into a dynamic layout.
IcedDante
You could try using a FrameLayout with the canvas and ListView as two children. Then in your onCreate method you can get the canvas by id, and work with it as you are currently.
Mayra
FrameLayout, eh? Alright- I'll check that out!
IcedDante