code problem finding id and index
<p>new to programming and android, so I really have no idea what im doing. can anyone tell me why this code returns incorrect values of -1 for index and a 10 digit number for id, when I clearly assign an id and the index should not be -1 because its 0 based??</p>

<p>I would think that the problem is somewhere in the code that gets the focused view, but ive tried findFocus and getCurrentFocus, and both return the same thing. Here is the code, thanks!</p>

<pre><code>llmain = (LinearLayout) findViewById(R.id.linearLayoutMain);
    linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    int pos = 0;

    View myView = linflater.inflate(R.layout.action, null);
    myView.setId(pos);
    pos++;
    llmain.addView(myView);
    myView.requestFocus();
    View v = getCurrentFocus();
    if(v instanceof EditText) {
       id = v.getId();
       index = llmain.indexOfChild(v);
       Context context = getApplicationContext();
       CharSequence text = "index is:" + index + "id is:" + id;
       int duration = Toast.LENGTH_SHORT;

       Toast toast = Toast.makeText(context, text, duration);
       toast.show();
    }
} 
</code></pre>
