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

  • Home
  • SEARCH
  • 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 6062683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:48+00:00 2026-05-23T09:04:48+00:00

I am trying to create a horizontalscrollview which is supposed to hold a few

  • 0

I am trying to create a horizontalscrollview which is supposed to hold a few views that are scrollable horizontally.

The initial view is a horizontal scroll view with a linear layout inside it

I have another view, something like a screen that shows weather for a city.

If i have 5 cities in my database, i would like to add 5 instances of the view into the horizontalscroll view. And each instance has its own events such as clicks and http requests.

I can create a horizontalscrollview from the xml, but i would like to do it dynamically. I have been looking around for some examples to try to get a starting point, but nothing seems to be out there.

Can somebody point me to the right direction?

This is my horizontalscrollview 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"
    android:orientation="vertical">
        <RelativeLayout android:layout_height="50dp"
            android:id="@+id/TableRow01" android:layout_width="fill_parent"
            android:background="#82db7a">
            <ImageView android:id="@+id/imageView1" android:src="@drawable/logo_topbar"
                android:layout_height="wrap_content" android:layout_width="wrap_content" />
            <ImageButton android:background="@drawable/topicon_btn"
                android:src="@drawable/btn_icon_locateme" android:layout_gravity="center_vertical"
                android:layout_height="45dp" android:id="@+id/locatemebtn"
                android:layout_width="wrap_content" android:layout_centerVertical="true"
                android:layout_alignParentRight="true" android:layout_margin="5dp" />
            <ImageButton android:background="@drawable/topicon_btn"
                android:src="@drawable/btn_icon_star" android:layout_height="45dp"
                android:id="@+id/favbtn" android:layout_width="wrap_content"
                android:layout_toLeftOf="@+id/locatemebtn" android:layout_alignTop="@+id/locatemebtn"
                android:layout_alignBottom="@+id/locatemebtn" />
        </RelativeLayout>     
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:fillViewport="true"
    android:id="@+id/scrollView1" android:layout_height="fill_parent"
    android:layout_width="fill_parent" >
    <LinearLayout android:layout_width="fill_parent"  android:layout_height="fill_parent" android_id="@+id/mainScroll">


    </LinearLayout>
</HorizontalScrollView>
</LinearLayout>

This is how i tried to add a view (just to test if it works, though i am not sure even if it works, the view is just a layout or layout with functionality)

LinearLayout mainscroll=(LinearLayout) findViewById(R.id.mainScroll);
         LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
         View view = vi.inflate(R.layout.weather_tab, null);
         mainscroll.addView(view);

Since a scrollview can only have one child, i added a linearlayout inside (not sure if it should be linear layout), and i want to add all the instances of my views into the linear layout.

P.S: i Have done the same application for iphone without too much pain. Android just seems to confuse me too much 🙁

  • 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-23T09:04:48+00:00Added an answer on May 23, 2026 at 9:04 am

    Well,it just happens to be an xml error, the android_id missed my eye, the linear layout does not take it, but was surprised it did’nt throw an error

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

Sidebar

Related Questions

I am trying create a trending system that displays which keywords are trending by
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create a black line in my view to separate text blocks but
Trying to create a macro which can be used for print debug messages when
I'm trying create a box in my Django app that displays text (and possibly
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I'm trying to write a table trigger which queries another table that is outside
I am trying create a small web application that allows a user to login
I am trying create a 'live' view where our clients can edit the colors
Trying to create a simple document that gets the parentNode then applies a background

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.