How do i change the value of an object from an inner method?
<p>I need to change the value of <code>newiconid[0]</code> to <code>arg2</code> from method <code>onItemSelected()</code>. And I need to use that value in <code>onClick()</code>. The following code does not work, it just keeps the value of <code>newiconid[0]</code> as <code>0</code>. How to accomplish this?</p>

<pre><code>@Override
public void onClick(DialogInterface dialog,
        int which) {
    final int newiconid[] = new int[1];
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(
                AdapterView&lt;?&gt; arg0, View arg1,
                int arg2, long arg3) {
            // TODO Auto-generated method stub
            System.out.println("" + arg1 + arg2
                    + arg3);
            newiconid[0] = arg2;
        }

        @Override
        public void onNothingSelected(
                AdapterView&lt;?&gt; arg0) {
            // TODO Auto-generated method stub

        }
    });
    // TODO Auto-generated method stub
    System.out.println("updateicon "+newiconid[0]+" "+itemid);
    datasource.updateVSIcon(newiconid[0], itemid);
}
</code></pre>
