I am adding a child view to a Linear Layout. The child views itself has some textview and imageviews in a Relativelayout.
The child view is added dynamically in the LinearLayout on clicking a button. Right now I am able to add the child view as shown in this pic.
http://dl.dropbox.com/u/50249620/SC20120926-031356.png
what I have to do is uniquely identify which child view has been clicked in order to show appropriate actions.
My code where I am adding the child view.
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customView1 = inflater.inflate(R.layout.people, null);
peopleName = (TextView) customView1.findViewById(R.id.peopleName);
peopleName.setText(autoComplete.getText());
customView1.setId(peopleInvitedRelativeLayout.getChildCount() + 1);
params4 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
customView1.setLayoutParams(params4);
peopleInvitedRelativeLayout.addView(customView1, params4);
}
});
Any help or suggestions would be appreciated. Thanks.
You can add a custom tag to any view simply by doing the following when you create the view
then later in the onClickListener find the tag with
setTag(Object o)will accept any kind of object be it a string, int or custom classEDIT
the clicklistener – create a class variable for it