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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:25:47+00:00 2026-06-14T18:25:47+00:00

I have a listView (vertical) and every list item has a horizontal list view

  • 0

I have a listView (vertical) and every list item has a horizontal list view (horizontal).

But the problem is when i scroll the horizontal scrollview in the row the vertical list is also calling getView()…

So, there is a huge performance hit..
So , can any one tell me a better solution to it ..

    public class GridViewAdapter extends BaseAdapter {

    List<List<Hotel>> gridDatasource;
    Context mContext;

    public GridViewAdapter(List<List<Hotel>> gridDatasource, Context context) {
        this.gridDatasource = gridDatasource;
        this.mContext = context;
    }

    public void setGridDatasource(List<List<Hotel>> gridDatasource) {
        this.gridDatasource = gridDatasource;
    }

    @Override
    public int getCount() {
        if (gridDatasource == null) {
            return 0;
        }
        return gridDatasource.size();
    }

    @Override
    public Object getItem(int position) {
        return gridDatasource.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        GridViewHolder holder;
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.gridview_table_cell,
                    null);

            holder = new GridViewHolder();
            holder.headerView = (TextView) convertView
                    .findViewById(R.id.gridViewRowHeader);
            holder.listView = (HorizontalListView) convertView
                    .findViewById(R.id.gridViewHorizontalListView);
            convertView.setTag(holder);
        } else {
            holder = (GridViewHolder) convertView.getTag();
            Log.d("TAG", "Reaching Here");
        }
        holder.headerView.setText("Hello From Sandeep");
        HorizontalListViewAdapter adapter = new HorizontalListViewAdapter(
                mContext, gridDatasource.get(position));
        holder.listView.setAdapter(adapter);
        return convertView;
    }

}

static class GridViewHolder {
    TextView headerView;
    HorizontalListView listView;
}

public class HorizontalListViewAdapter extends BaseAdapter {
    Context mContext;
    List<Hotel> mHotels;

    public HorizontalListViewAdapter(Context context, List<Hotel> hotels) {
        this.mContext = context;
        this.mHotels = hotels;
    }

    @Override
    public int getCount() {
        if (mHotels == null) {
            return 0;
        }
        return mHotels.size();
    }

    @Override
    public Object getItem(int position) {
        return mHotels.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        HotelCell cell = (HotelCell) convertView;
        if (cell == null) {
            cell = new HotelCell(mContext);
        } else {
            Log.d("TAG", "Reached here 2");
        }
        cell.setHotel(mHotels.get(position));
        cell.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,
                        HotelDetailActivity.class);
                intent.putExtra("DATA", ((HotelCell) v).getHotel());
                startActivity(intent);
            }
        });
        cell.setPadding(0, 0, 10, 0);
        return cell;
    }
}
  • 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-14T18:25:49+00:00Added an answer on June 14, 2026 at 6:25 pm

    Dear i suggest to try My this Code

    public View getView(final int position, View convertView, ViewGroup parent) 
        {
             View v = convertView;
             ViewHolder holder;
    
             if (v == null) 
             {
                 v = inflater.inflate(R.layout.custom_image_layout, null);
                 holder = new ViewHolder();
                 holder.txtFileName = (TextView) v.findViewById(R.id.txtFileName);
                 holder.imageView = (ImageView) v.findViewById(R.id.imgView);
                 v.setTag(holder);
             } else 
             {
                 holder = (ViewHolder) v.getTag();
             }
    holder.imageView.setImageBitmap(bm);
    holder.txtFileName.setText(""+nameoffile);
    return v;
        }
        static class ViewHolder 
        {
             public ImageView imageView;
             public TextView txtFileName;
        }
    

    Use The Holder Class

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

Sidebar

Related Questions

I have a ListView in my Layout. <ListView android:id=@+id/list_infoitems android:layout_width=fill_parent android:layout_height=wrap_content/> Every list item
I have a WinRT/C#/XAML app with a view that has a vertical ListView of
I have a ListView where each row has a fixed height. Every row contains,
This is my ListView xml file and i have different xml for row(every item
I have a Listview to show some item and i have also used an
I have a ListView which I've created a custom view for each row. My
I have a ListView that uses SimpleAdapter, each row has 2 TextViews, and I
In an activity, I have list of buttons and a listview. For every category
I am using ListView and for every row I have row_item.xml and I inflate
I have a ListView within a panel that has vertical scrolling enabled and absolute

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.