I\'ve got a little piece of xml, which I\'ll be using in a lot of places in my app. For this reason I want to store it in a separate file. So I created mywidget.xml in which
Easiest Solution
LinearLayout item = (LinearLayout )findViewById(R.id.item);//where you want to add/inflate a view as a child
View child = getLayoutInflater().inflate(R.layout.child, null);//child.xml
item.addView(child);
ImageView Imgitem = (ImageView ) child.findViewById(R.id.item_img);
Imgitem.setOnClick(new ...