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

Dropdown to horizontal carousel jQuery plug-in

jquery jquery-ui select combobox drop-down-menu

I am looking for any jquery/jquery-ui plugin to convert select html element (drop-down list) to a nice looking "carousel". Not image carousel, but something similar to jQuery-ui datepicker component

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.