Get values from Dynamic list
<p>Good day everyone, </p>

<p>I'm learning Android development and I try to build some dynamic lists for my application. And I'm stuck... like for 4 hours already.  </p>

<p>I have two layouts:
1. main.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" &gt;

&lt;LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:id="@+id/action_buttons"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:gravity="center"
    &gt;

&lt;Button
    android:id="@+id/button_count"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_calculate" /&gt;

&lt;Button
    android:id="@+id/button_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/button_count"
    android:text="@string/button_add" /&gt;
&lt;/LinearLayout&gt;    

&lt;ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_below="@+id/action_buttons"
    &gt;      

    &lt;LinearLayout
        android:id="@+id/action_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" &gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;    
&lt;/RelativeLayout&gt;
</code></pre>

<ol>
<li><p>action_list_item.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_list_item_root"
android:layout_width="fill_parent"
android:layout_height="wrap_content" &gt;

&lt;EditText
    android:id="@+id/action_list_item_edittext_drinkName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/action_list_item_button_remove"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/action_list_item_title"
    android:padding="10dp" /&gt;

&lt;EditText
    android:id="@+id/action_list_item_edittext_drinkPercent"
    android:text="40"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/action_list_item_edittext_drinkAmount"
    android:inputType="number"
    android:padding="10dp"/&gt;

&lt;EditText
    android:id="@+id/action_list_item_edittext_drinkAmount"
    android:text="0.0"        
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/action_list_item_button_remove"
    android:layout_alignBottom="@+id/action_list_item_button_remove"
    android:inputType="numberDecimal"      
    android:width="50dp"
    android:padding="10dp" /&gt;
&lt;Button
    android:id="@+id/action_list_item_button_remove"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="@string/action_list_item_button_remove" /&gt;
</code></pre>

<p></p></li>
</ol>

<p>And code that creates dynamic list:</p>

<pre><code>public class MainActivity extends Activity {
  LinearLayout actionList = null;
  private Button btnAdd;
  private Button btnCalculate;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    initActivityElements();

  }

  private void initActivityElements() {
    initAddButton();
    initCalculateButton();
  }

  private void initCalculateButton() {
    btnCalculate = (Button) findViewById(R.id.button_count);
    btnCalculate.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        TextView amount = (TextView) findViewById(R.id.action_list_item_edittext_drinkAmount);

//this retrives TextView value from first list
        Toast.makeText(getApplicationContext(), amount.getText().toString(),
            Toast.LENGTH_SHORT)
            .show();

      }
    });
  }

  private void initAddButton() {
    actionList = (LinearLayout) findViewById(R.id.action_list);
    btnAdd = (Button) findViewById(R.id.button_add);

    btnAdd.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        RelativeLayout listItem = (RelativeLayout) View.inflate(
            MainActivity.this, R.layout.action_list_item, null);

        TextView name = (TextView) listItem
            .findViewById(R.id.action_list_item_edittext_drinkName);
        name.setText("Here is the Title " + actionList.getChildCount());

        listItem.findViewById(R.id.action_list_item_button_remove)
            .setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                actionList.removeView((View) v.getParent());
              }
            });

        actionList.addView(listItem);
      }
    });
  }
</code></pre>

<p>My problem is that I need to get all data from TextView boxes (Amount, Percent), but I can retrive that data only from first item of a list (look at onClickListener for <strong>btnCalculate</strong>) and can't figure out how to do it, but tried to add 'unique ids' for view (but that brakes layout, badly), tried setting Tags but again with no luck.</p>

<p>Maybe anyone can give a tip? I bet there is some easy way to do it, but I'm failing to find it and google is no help here.</p>

<p>Thanks</p>
