Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating custom components using regular android components
    primarykey
    data
    text
    <p>basically I want to encapsulate a simple component from code that I already have.</p> <p>Basically it's a <code>LinearLayout</code> with buttons inside. These buttons will make changes to a <code>ListView</code>, and there is also some other small stuff that it will do.</p> <p>Currently I have a XML layout with those, and I programmatically setup everything else: the buttons, the interaction between the list and the other small stuff.</p> <p>Obviously I thought to myself, let's encapsulate this.</p> <p>I started out trying to extend the <code>LinearLayout</code> and adding the buttons. Already I have no idea how to inflate the buttons to add to the view What method do I override to create this buttons just before the view gets created without messing with the measures and inflations, etc.</p> <p>I've looked around but the custom components I see are either completely new components or components that simply add small functionality to the custom ones.</p> <p>Is there some guidelines for doing this? Good tutorials/examples?</p> <p>Any help is appreciated. Thanks !</p> <p>EDIT:</p> <p>Okay, here is a little more specific stuff.</p> <p>Basically I want to create a <code>View</code> that holds filter buttons for a <code>ListView</code>. This will be used in different places with different filters, so I need flexibility for the buttons.</p> <p>Basically I'd like to do something like this:</p> <pre><code>CustomView view = new CustomView(activity); view.addButton("Lala", new OnFilterClickListener { onClick(ListView list, View v) { // Do the filtering } }); mListView.addHeaderView(view); </code></pre> <p>I want the view to adapt it's weights for showing the buttons, show the user which filter is active, stuff like that.</p> <p>But I still don't really know how to make those dynamically added buttons appear, where do I generate them, how to inflate them and stuff like that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload