Can't reach my (final) button inside my OnClickListener function
<p>My final goal of this snippet is to:  </p>

<ol>
<li>call a Dialog(Interface) from a button.</li>
<li>let the end user select an option (in a list of 5 options)</li>
<li>change the button text to the selected option</li>
</ol>

<p>Currently I have this:</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
   setLayoutState();
   // rest of code omitted
}
</code></pre>

<p>then the setLayoutState() that instatiates the button</p>

<pre><code>public void setLayoutState() {
    setContentView(R.layout.main);
    Button rate = (Button) findViewById(R.id.ratebutton);
    rate.setOnClickListener(onRatePress); 
}
</code></pre>

<p><b>So here:</b> <i>setOnClickListener calls to a separate function (to keep things clean, the Activity has got a lot of buttons)</i></p>

<pre><code>private final View.OnClickListener onRatePress = new View.OnClickListener() {
public void onClick(View v) {

final ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
                context, R.array.rates, android.R.layout.select_dialog_item );
        adapter.setDropDownViewResource(android.R.layout.select_dialog_item);

        new AlertDialog.Builder(context).setTitle("Rate this item!")
       .setAdapter(adapter, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                Common.makeToast(context,adapter.getItem(which) + "", 3000);
                Button rate = (Button) findViewById(R.id.ratebutton);
                rate.setText(adapter.getItem(which)+"");
                // TODO: user specific action
                dialog.dismiss();
            }
        }).create().show();
    }
};
</code></pre>

<p>While <b>this works fine</b> I was wondering if there is a way I can pull this off <b>without</b> redeclaring the Button rate inside the Dialog's onClick</p>

<p>I've already tried declaring the button as final in the top part, but that won't let me call the button in the Dialog's onClick.</p>
