Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3752558
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:15:35+00:00 2026-05-19T09:15:35+00:00

Hey I want to make a view appear below the last that has been

  • 0

Hey I want to make a view appear below the last that has been created.

It is showing like this:

alt text

I want to make the next view show below the last one, so for each new view added, it shows below. Understand?

Here is my code. The xml file and the java file.

listitem.xml

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:id="@+id/linearId" 
    android:padding="6dip"
    >
    <ImageView 
        android:id="@+id/icon" 
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" 
        android:layout_marginRight="6dip"
        android:src="@drawable/icon" 
        />
    <LinearLayout 
        android:orientation="vertical"
        android:layout_width="0dip" android:layout_weight="1"
        android:layout_height="fill_parent"
        >
        <TextView 
            android:id="@+id/txt1" 
            android:layout_width="fill_parent"
            android:layout_height="0dip" 
            android:layout_weight="1"
            android:textSize="20sp" 
            android:gravity="center_vertical"
            android:text="My Application" 
            />
        <TextView 
            android:id="@+id/txt2" 
            android:layout_width="fill_parent"
            android:layout_height="0dip" 
            android:layout_weight="1"
            android:singleLine="true" 
            android:ellipsize="marquee"
            android:text="Simple application that shows how to use RelativeLayout"
            android:textSize="10sp" 
            />
    </LinearLayout>
</LinearLayout>

RatedCalls.java

public class RatedCalls extends Activity {

private static final String LOG_TAG = "RatedCalls";
private TableLayout table;
private CallDataHelper cdh;
private TableRow row;
private TableRow row2;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.listitem);

    Log.i(LOG_TAG, "calling from onCreate()");

    cdh = new CallDataHelper(this);

    startService(new Intent(this, RatedCallsService.class));
    Log.i(LOG_TAG, "Service called.");
    Log.i(LOG_TAG, "before call fillList");

    List<String> ratedCalls = new ArrayList<String>();
    ratedCalls = this.cdh.selectTopCalls();

    LayoutInflater inflater = (LayoutInflater) this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout ll = (LinearLayout) this.findViewById(R.id.linearId);

    for (int i = 0; i < 1; i++) {
        View item = inflater.inflate(R.layout.listitem, null);

        TextView x = (TextView) item.findViewById(R.id.txt1);
        x.setText(ratedCalls.get(0));

        TextView ht = (TextView) item.findViewById(R.id.txt2);
        ht.setText(ratedCalls.get(1));

        ll.addView(item, ViewGroup.LayoutParams.WRAP_CONTENT);


    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:15:36+00:00Added an answer on May 19, 2026 at 9:15 am

    To work so you need to create two different xml for each inflater

    In your layout folder,new xml layout/main2.xml

    <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"    
            android:layout_height="fill_parent">    
                 <ImageView
                android:id="@+id/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="6dip"
                android:src="@drawable/icon"
                />
                <TextView
                    android:id="@+id/txt1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="20sp"
                    android:gravity="center_vertical"
                    android:text="My Application"
                    />
                <TextView
                    android:id="@+id/txt2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:singleLine="true"
                    android:ellipsize="marquee"
                    android:text="Simple application that shows how to use RelativeLayout"
                    android:textSize="10sp"
                    />    
            </LinearLayout>
    

    Then your layout/main.xml

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/linearId"
        android:orientation="vertical"
        >
        <TextView android:id="@+id/rowCount"    android:layout_width="wrap_content"
        android:layout_height="wrap_content" ></TextView>
         <LinearLayout
             android:id="@+id/linearId2"
           android:layout_width="fill_parent"
        android:layout_height="?android:attr/listPreferredItemHeight"
        android:padding="6dip"> 
             </LinearLayout>
    </LinearLayout>
    

    Then you can set you activity like this

     private int ELEMENTINEACHROW=2 ;
        private int NOOFROW = 4;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout ll = (LinearLayout) this.findViewById(R.id.linearId);
            for (int j = 0; j < NOOFROW; j++) {
                View itemMain = inflater.inflate(R.layout.main, null, false);
                TextView rowCount = (TextView) itemMain.findViewById(R.id.rowCount);
                rowCount.setText("Row:"+(j+1));
                LinearLayout ll2 = (LinearLayout) itemMain.findViewById(R.id.linearId2);
                for (int i = 0; i < ELEMENTINEACHROW; i++) {
                    View item = inflater.inflate(R.layout.main2, null, false);
    
                    TextView x = (TextView) item.findViewById(R.id.txt1);
                    x.setText("test");
    
                    TextView ht = (TextView) item.findViewById(R.id.txt2);
                    ht.setText("good");
    
                    ll2.addView(item, ViewGroup.LayoutParams.FILL_PARENT);
                }
                ll.addView(itemMain, ViewGroup.LayoutParams.FILL_PARENT);
            }
        }
    

    Hope it give you the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, what i want to do is to make a int that will be
Hey guys, I want to make a function loop over all elements that have
Hey, I want to make the Text of a RadioButton appear on the left
Hey i am making a app in which i want to make emulator that
Hey I have a view that has a button that when pressed should modally
Hey Friends I want to make a form builder using Yii. For that I
Hey I want to select records with name O'Neil, How can i do that
Hey guys, I want to store a categorized list of URLs. This is an
Hey i dont know if that is possible but i want to set a
Hey guys, I'm starting to play around with Objective-C and I want to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.