TabHost: What if I need to handle onOptionsItemSelected each in separate Tab/Activity
<p>I need to have a <code>TabHost</code> consisting of two <code>tabs</code> where each <code>tab</code> represented by a separate <code>Activity</code>. Each <code>Activity</code> has its own data fields and methods to operate on them. I want each <code>tab</code> to have its own <code>menu</code> and for this <code>menu</code> I need <code>onOptionsItemSelected()</code> method to be a part of the <code>class</code> to make it able to invoke methods of this <code>class</code>. </p>

<p>What the best approach would it be to implement this? </p>

<p>I've started with <code>menu</code> definition in the class which represents <code>TabHost</code>, but then faced with a problem I don't have an access to methods of my <code>Activities</code>. I decided to make methods of <code>Activities</code> <code>static</code> to have access to them but finally I would need to define almost all fields of these <code>Activities</code> as static which doesn't seem to be a good solution for me. </p>

<p><strong>Update</strong>:</p>

<hr>

<p>It became much easier then I thought. In onOptionsItemSelected() you can get the current <code>Activity</code> of your opened <code>tab</code>.</p>

<pre><code>SecondActivity sa = (SecondActivity)this.getCurrentActivity()
sa.myPublicMethod();
</code></pre>
