Java code optimalization - Two functions into one
<p>Hello I have this code:</p>

<pre><code>this.firstBtn.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {

        final CharSequence[] items = {"1", "2", "3"};
        AlertDialog.Builder builder = new AlertDialog.Builder(SlovnikoidActivity.this);
        builder.setTitle("test");
        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
                langFrom.setText(items[item]);
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
});

this.secondBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            final CharSequence[] items = {"1", "2", "3"};
            AlertDialog.Builder builder = new AlertDialog.Builder(SlovnikoidActivity.this);
            builder.setTitle("test");
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
                    langFrom.setText(items[item]);
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });
</code></pre>

<p>There are just two different parts: <code>this.firstBtn</code> and <code>this.secondBtn</code>
Is there a way how to merge it? For example when I click on <code>firstBtn</code> it calls a function <code>foo(firstBtn)</code> and <code>secondBtn</code> calls <code>foo(secondBtn)</code> and the rest would work the same? 
I'm not sure about syntax etc. because I'm new to Java and Android development today.</p>

<p>Thanks</p>
