Android:  embedded controls in multiply included compound control restore to same state
<p>I am customizing an <a href="https://github.com/mrn/numberpicker" rel="nofollow">Android control</a>. This control uses a merge layout containing an edit field (fluff left out):</p>

<pre><code>    &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"&gt;
   ...
    &lt;EditText android:id="@+id/numberpicker_input"&gt;
        ...
    /&gt;
    ...
    &lt;/merge&gt;
</code></pre>

<p>This works fine for a single control. However, if I put multiple instances of this control in a layout, it results in weird behaviour when rotating a device from portrait to landscape. All controls get the same value restored and callbacks get attached to the wrong control instance.</p>

<p>Upon examination, it emerged that the embedded edit controls have the exact same id value. </p>

<p>The relevant java source looks like this:</p>

<pre><code>public class NumberPicker extends LinearLayout implements OnClickListener,
        OnFocusChangeListener, OnLongClickListener, OnEditorActionListener {

    private final EditText mText;
....
    public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs);

        Log.d(TAG, "Numberpicker create, have id: " + getId() );

        setOrientation(VERTICAL);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.number_picker, this, true);
...

        mText = (EditText) findViewById(R.id.numberpicker_input);
...    
    }
}
</code></pre>

<p>Now, consider the value of R.id.numberpicker_input, when you have three separate instances of a NumberPicker in a layout. In each instance, the edittext field will have the same id.</p>

<p>To get the custom control to work properly, I need the id's of the embedded edit controls to be unique. How can I fix this?</p>
