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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:54:09+00:00 2026-06-07T11:54:09+00:00

I am currently using Gallery to display a list of items. Everything work fine

  • 0

I am currently using Gallery to display a list of items. Everything work fine except the center locking feature which I don’t like. I found this HorizontalListView implementation from here http://www.dev-smart.com/archives/34 and want using it to replace the Android Gallery. I downloaded the HorizontalListView.java, put it in my project and change Gallery to HorizontalListView, but when I run the app, nothing show up. The items of the Gallery (HorizontalListView now) is set by using ArrayAdapter. Did I set up anything wrong? Here’s the code:

Layout HorizontalListView:

    <com.myapp.HorizontalListView
      android:id="@+id/related"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="#ebebeb" >
    </com.myapp.HorizontalListView>

HorizontalListView item:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >


<ImageView
    android:id="@+id/gameicon"
    android:layout_width="120dip"
    android:layout_height="120dip"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:src="@drawable/iconbig" />

<TextView
    android:id="@+id/gamename"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:gravity="center_horizontal|center_vertical"
    android:text="Title"
    android:textSize="15sp"
    android:textColor="#000000" 
    android:textStyle="bold"/>
</LinearLayout>

Adapter for items:

public class RelatedListAdapter extends ArrayAdapter<GameInfo> {

private ArrayList<GameInfo> items;
public static HashMap<String, String> relatedImageMap;

public RelatedListAdapter(Context context, int textViewResourceId,
        ArrayList<GameInfo> items) {
    super(context, textViewResourceId, items);
    this.items = items;
    if (relatedImageMap == null)
        relatedImageMap = new HashMap<String, String>();
}

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater mInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = mInflater.inflate(R.layout.related_items, null);
    }

    GameInfo game = items.get(position);
    if (game != null) {
        TextView name = (TextView) v.findViewById(R.id.gamename);
        ImageView icon = (ImageView) v.findViewById(R.id.gameicon);
        if (name != null) {         
            name.setBackgroundColor(Color.parseColor("#ebebeb"));
            name.setText(NewDetailActivity.TruncateString(game.getName(), 8) );
        }
        if (icon != null) {
            icon.setBackgroundColor(Color.parseColor("#ebebeb"));
            if (EfficientAdapter.imageMap.containsKey(game.getId())) {
                String filePath = EfficientAdapter.imageMap.get(game
                        .getId());
                Bitmap bm = BitmapFactory.decodeFile(filePath);
                icon.setImageBitmap(bm);
            } else if (relatedImageMap.containsKey(game.getId())) {
                String filePath = relatedImageMap.get(game.getId());
                Bitmap bm = BitmapFactory.decodeFile(filePath);
                icon.setImageBitmap(bm);
            } else {
                String storagePath = Environment
                        .getExternalStorageDirectory().toString()
                        + getContext().getResources().getString(
                                R.string.imgCacheFolder);
                String image = game.getImgUrl().replaceAll(
                        "[^a-zA-Z 0-9]+", "");
                String filePath = storagePath + image;
                EfficientAdapter.LoadImageFromWebOperations(game.getImgUrl(),
                        filePath, null);
                if (relatedImageMap != null) {
                    synchronized (relatedImageMap) {
                        relatedImageMap.put(game.getId(), filePath);
                    }
                }
                Bitmap bm = BitmapFactory.decodeFile(filePath);
                icon.setImageBitmap(bm);
            }
        }
    }

    return v;
}

}

And in my Activity:

HorizontalListView related = (HorizontalListView) findViewById(R.id.related);
data = new ArrayList<GameInfo>();
adap = new RelatedListAdapter(this, R.layout.related_items, data);
related.setAdapter(adap);

If I change HorizontalListView to Gallery, everything work fine and the list is shown. But using HorizontalListView, nothing show up. Can anyone help me out with this?

EDIT: I found out something different now. The HorizontalListView did show up, but not the first time I open it. For example I have 3 tab and HorizontalListView in tab 3. When I start activity, it show tab 1. Then I click tab 3, nothing show up. I changed to tab 1 or tab 2, then return to tab 3, the list is showing now. Strange huh? Does anybody know why?

  • 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-06-07T11:54:13+00:00Added an answer on June 7, 2026 at 11:54 am

    I also used the HorizontalListView in the before. But it is too hard to adapt to suite my particular use case.

    Then I found this class HorizontalScrollView. It is defined in android SDK – much more easy to use and versatile.

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

Sidebar

Related Questions

I'm currently using Shadowbox.js to my gallery and I want to disable the right
I'm currently using this code: var gallery = $('ul#gallery').children(); $(gallery).filter(':even').not(':last').hover(function () {$(this).toggleClass('next')}); I'm trying
I'm writing an application that shows a lot of images (currently using Gallery, but
We are using SuperSlidShow Plugin to display gallery of images in our post. However
I'm using simple gallery script which dynamically loads image when user clicks on thumbnail
I am currently building a gallery web application using php. I am currently developping
I'm currently trying to create a gallery of pictures loaded from Internet. I'm using
I am using this photo gallery from Codrops to display the images. I've added
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using Google Analytics as a supplement to our paid tracking software, but neither

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.