Adding multiple framelayout in a linearlayout programmatically

I need to overlap an image view with textview. And this combined view will be repeated 100 times in a LinearLayout. I was thinking of using FrameLayout in LinearLayout and Repeating the FrameLayout in LinearLayout 100 times when FrameLayout holds the imageview and textview overlapped. Need to do this programatically not from xml file.

I added the image and textview to framelayout first then tried to add the framelayout to linearlayout. But it says : the specified child has already a parent.. so not working. Can you please show me in code? Thanks for your help.

it is going to be like this, but need to be done programmaticaly

---linear layout--------------
|frame layout----------------|
||txt view on top of img view|
frame layout will be repeated|

---/end of linear layout------

Also here is the separated code:

public void onCreate(Bundle savedInstanceState) {

        LinearLayout dynamicview = (LinearLayout) findViewById(;

        FrameLayout barFrameLayout = new FrameLayout(this);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,

        LinearLayout.LayoutParams slparams1 = new LinearLayout.LayoutParams(

        for (int i = 65; i <= 75; i++) {
            TextView catTV = new TextView(this);
            catTV.setText("===" + Character.toString((char) i) + "===");

            ImageView iv = new ImageView(this);




Here is the code to demonstrate what you are trying to achieve. I have used RelativeLayout, which is very flexible, you can position the elements easily relative to others.( if you need to change to FrameLayout you can change ).

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ExampleLayout extends LinearLayout{

public ExampleLayout(Context context,AttributeSet attrs){

    for(int i =0; i< 100; i++){

        RelativeLayout childLayout = new RelativeLayout(context);

        ImageView img  = new ImageView(context);
        TextView text = new TextView(context);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        childLayout.addView(img, params);

        params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        childLayout.addView(text, params);

        LinearLayout.LayoutParams parentParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);           

You can then use the ExampleLayout class to add it to any of the layout.xml file.

Need Your Help

How do I search for all my git repositories on my Mac?

git osx apple

I'm curious where I've scattered my git repositories across my mac. I'm trying to figure out how I could do a search to find them all so I can organize my life a bit. How can I do this?

Handling versions

mysql database innodb

Currently I'm working on a website for a client, who deals in software plugins. The client needs to be able to upload Products, and for these products different Versions, Updates and Patches. For