How to handle dynamically inflated layout content (Same Layout inflated multiple times)

323 views Asked by At

I have a Linear layout and inside which there are few dropdown and text views,now i want to inflate the layout each time on click of "add more" button, below is the code for inflating the layout. the problem i am facing is to assign the id to each inflated layout content .Inorder to handle the content the inlfated layout i need the unique id for each content for each time i am inflating the layout.

LayoutInflater inflater = (LayoutInflater)   getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row_view;
row_view = (View)inflater.inflate(R.layout.inflatefloor,null);
                inflatefloordetails.addView(row_view);

here inflatefloor is the layout to inflate and inflatefloordetails is the main root layout inside which layout is to be inflated and i am inflating the inflatefloor layout each time on button click.

New to android pardon if anyone finds the question silly.

Note:Check out link below if anyone is facing similar problem, I found this link useful.

How to set Id of dynamic created layout?

1

There are 1 answers

0
Junaid Fahad On

I think it will be helpful.

you can put any object when set the tag to be unique:

yourView.setTag(Object object);

and to retrive it:

object.indexOf(yourView.getTag())

Otherwise you have to use custom view.