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 6586943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:51:17+00:00 2026-05-25T16:51:17+00:00

I am working with android, i want to make horizontal scroll view at run

  • 0

I am working with android, i want to make horizontal scroll view at run time, means i want to make this horizontal view by java code.

this is my code of java class

package com.pericent;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;

public class HelloTabWidget extends TabActivity  {

    private String TAG="HelloTabWidget";

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

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

        // Create an Intent to launch an Activity for the tab (to be reused)
                intent = new Intent().setClass(this,ArtistsActivity.class);
                Log.v(TAG,"---artist activity is called---");
        // Initialize a TabSpec for each tab and add it to the TabHost
                spec = tabHost.newTabSpec("artists").setIndicator("Artists",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
                tabHost.addTab(spec);
        }
        setContentView(tabHost);
   }
} 


this is activity ArtistActivity which  is used in above code to make Tab Widget:-
package com.pericent;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class ArtistsActivity extends Activity {
    private String TAG="ArtistsActivity";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textview=new TextView(this);
        textview.setText("This is Artist Activity");
        setContentView(textview);
        Log.v(TAG,"---in artist activity---");
    }
}

and this is the xml file used in above code:-
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- When selected, use grey -->
    <item android:drawable="@drawable/ic_tab_artists_grey"
          android:state_selected="true" />
    <!-- When not selected, use white-->
    <item android:drawable="@drawable/ic_tab_artists_white" />
</selector>
this above xml is used to create tab widget.

this is the output of my above code:-

enter image description here

in my output all widget are displaying in the screen but i want to display 4 tabs at a time, and other must show after scrolling. So please suggest me how can i add scrollable facility in my java code ?

Thank you in advance.

  • 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-25T16:51:18+00:00Added an answer on May 25, 2026 at 4:51 pm

    try like this

    HorizontalScrollView hr=new HorizontalScrollView(this);
    hr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
    
    LinearLayout layout=new LinearLayout(this);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
    
    for(int i=0;i<100;i++){
        TextView txt=new TextView(this);
        txt.setText("Text " + i );
        layout.addView(txt);
    }
    hr.addView(layout);
    
    mainLayout.addView(hr);
    

    in the above code i have added text view. but you can add any view instead of text view.

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

Sidebar

Related Questions

I am working in android, i want to make a scrollview. this is my
I am working in android . I want to make sharedpreference in my code,
i am working in android. I want to make TabHost and Tab widget. this
I have some code which is working in iphone and i want to make
I just started working on a new Eclipse Android project and want to make
I want to make a http request with android. is use this: void testHTTP()
I'm working on a relatively simple Android app. I want it to have an
I am working in android. I want to show a list of events. I
I want to make a page for android which is refreshing in every sec
I want to get fling gesture detection working in my Android application. What I

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.