How to get the resource ID for Multiple view with same type in Android

330 Views Asked by At

I want to create multiple views of same type.I have created that here is the code.

    LinearLayout mainRoot = (LinearLayout) findViewById(R.id.wrapper);          
    LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v=inflater.inflate(R.layout.customlayout, null);
    mainRoot.addView(v);

Custom layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"   
    android:background="#ffffff"
    android:id="@+id/subroot"
 >
<EditText
                 android:id="@+id/name"
                 android:layout_width="wrap_content"
                 android:layout_height="50dip"
                 android:layout_alignParentLeft="true"
                 android:layout_alignParentRight="true"
                 android:layout_below="@+id/undeline"
                 android:layout_marginTop="10dip"
                 android:ems="10"
                 android:inputType="textPersonName"
                 android:padding="5dip"
 />
<Button
      android:id="@+id/allegybutton1"
      style="?android:attr/buttonStyleSmall"
      android:layout_width="35dip"
      android:layout_height="35dip"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
    />
</RelativeLayout>

Now Suppose I have created 10 number of views of same type .How can i differentiate each resource id.

for example

EditText username = (EditText)v.findViewById(R.id.name);

For 10 views the Resource id is same right !! Is there any possibilities to differentiate the ids.

How can I set the value for each EditText.

Could somebody help me out here!!

Anyhelp will be Great.!! Thanks.

0

There are 0 best solutions below