"Header" Views and buttons: how do I attach listeners to Buttons in a "header" that does not have its own Activity?
<p>Hey,
I have touched on this question <a href="http://stackoverflow.com/questions/2013433/whats-the-right-choice-create-new-activities-or-just-create-a-different-layout-a">here</a>, where Christopher gave an answer to this, but I dont really get it so I thought its time to make it a real question, not just a "follow up" =)
<hr></p>

<p>As it stands, the application Im writing has 4 different screens: 
1. Screen 1 - list of nodes (main screen) 
2. Screen 2 - options menu, tableLayout with buttons 
3. Screen 3 - navigation 
4. Screen 4 - text details on version etc</p>

<p>These screens can be navigated to/from using a "header" View that is placed on top. the header then has 4 different buttons:</p>

<pre><code>+--------------------+
| menu with buttons  |
+--------------------+
|                    |
|                    |
|                    |
|  C O N T E N T     |
|                    |
|                    |
|                    |
+--------------------+
</code></pre>

<p>The header is just an XML-file (header.xml) with a few buttons. That header.xml is the included in the Layouts using the include-markup. For example, the main.xml has the line:</p>

<pre><code>&lt;include layout="@layout/header"&gt;&lt;/include&gt;
</code></pre>

<p><b>The header show up alright, but the question is - what is the correct approach to attach OnClickListeners for the buttons in the header?</b></p>

<p>Christopher <a href="http://stackoverflow.com/questions/2013433/whats-the-right-choice-create-new-activities-or-just-create-a-different-layout-a">pointed out</a> that you could create an Activity class and do the hooks there, like this:</p>

<pre><code>public class BaseActivity extends Activity {
    protected View.OnClickListener mButtonListener;

    protected void setupHeaderButtons() {
        findViewById(R.id.header_btn_1).setOnClickListener(mButtonListener);
        // ...
        findViewById(R.id.header_btn_n).setOnClickListener(mButtonListener);
    }
}

public class FirstActivity extends BaseActivity {
    @Override
    public void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.first_activity);

        // This needs to be done *after* the View has been inflated
        setupHeaderButtons();
    }
}
</code></pre>

<p>First, I cant make it work since the method <i> setupHeaderButtons</i> isnt accessible from FirstActivity.
Secondly, is this the right way to go at it?</p>

<p>Regards</p>
