Encapsulate layout functionality on a class
<p>Currently I'm working on an Android application wich has a banner on top of it, I'm using a layout like this.</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" &gt;

&lt;RelativeLayout
    android:id="@+id/banner"
    android:layout_width="fill_parent"
    android:layout_height="60dip"&gt;
&lt;/RelativeLayout&gt;

&lt;LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" &gt;

    &lt;!-- other stuff --&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>Defining "banner" on other xml to inflate when activity is created, like this:</p>

<pre><code>control = (RelativeLayout)findViewById(R.id.banner_top);
LayoutInflater li = (LayoutInflater)getLayoutInflater();
li.inflate(R.layout.layout_banner, control);

control.findViewById(R.id.btnShow).setOnClickListener(
    new OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(InfoApp.this, Details.class));
        }
    });
</code></pre>

<p>It works fine but I realize that I'll use this banner many times, and each time I'll use it I have to re-code all events, so, that is exactly the question... Is there any way to encapsulate this functionality on a class?</p>

<p>Sorry for making a very general question but I just don't realize how to do that... Thanks in advice...</p>
