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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:06:38+00:00 2026-05-19T17:06:38+00:00

I feel a bit stupid as i can’t find the answer to this question,

  • 0

I feel a bit stupid as i can’t find the answer to this question, which makes me think i’m actually asking the wrong question. However, here goes…

I have a list view, and a listviewitem defined in xml, with a couple of fields, nothing special. All set to visible.

Then I bind to my ListView using a custom ArrayAdapter, and want to hide one of my text views, on row 5. However, it seems to be hiding my TextView on item 0 and item 5. Which is a bit odd? I’ve simplified the code, to reproduce the problem and hopefully someone will be able to help me…

My Adapter

public class MenuScreenAdapter extends ArrayAdapter<String>
{
    private List<String> _items;
    private Context _context;

    public MenuScreenAdapter(Context context, List<String> items)
    {
        super(context, R.layout.list_menu_item, items);

        _context = context;
        _items = items;
    }

    private MenuScreenAdapter(Context context, int textViewResourceId)
    {
        super(context, textViewResourceId); 
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        View v = convertView;

        if (v == null)
        {
            LayoutInflater vi = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_menu_item, null);
        }
        String o = _items.get(position);    
        if (o != null)
        {
            TextView tt = (TextView) v.findViewById(R.id.list_menu_item_name);
            if (tt != null)
                tt.setText(o);

            if (position == 5)
                tt.setVisibility(View.GONE);
        }
        return v;
    }
}

My Binding Code

    // Load everything up that we need
    List<String> items = new ArrayList<String>();
    items.add("One");
    items.add("Two");
    items.add("Three");
    items.add("Four");
    items.add("Five");
    items.add("Six");
    items.add("Seven");
    items.add("Eight");
    items.add("Nine");
    items.add("Ten");

    // Get the ListView, and set it's adapter. The HomeScreenAdapter
    // takes care of the rest
    ListView homeScreenListView = (ListView) _mainActivity.findViewById(R.id.view_home_list);
    homeScreenListView.setOnItemClickListener(ItemSelected);
    homeScreenListView.setAdapter(new MenuScreenAdapter(_mainActivity.getBaseContext(), items));

Thanks 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-19T17:06:39+00:00Added an answer on May 19, 2026 at 5:06 pm

    Since row views are reused by ArrayAdapter, once the View.GONE is set, it will cary on to the next row, where this view will be reused. In your case, you set View.GONE to textview in the fifth row, moved list a little and arrayadapter decided to reuse your fifth row layout to display the first row, since no changes were done to it, the textView still remains hidden.

    Just do the:

    if (position == 5) {
                tt.setVisibility(View.GONE);
    } else {
                tt.setVisibility(View.VISIBLE);
    }
    

    P.S. If you still haven’t, watch a presentation about ListViews from google. Tons of usefult info there. ListViews

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

Sidebar

Related Questions

As a Rails developer I feel a bit stupid asking this question but hopefully
I feel a bit embarrassed asking this questions, but how the heck can I
I feel a bit silly asking this as the answer is bound to be
I feel pretty stupid asking this, but as I don't know the answer, I'm
I feel a little bit silly asking this, but I haven't been able to
This is a bit of a Visual Studio question. I feel with all the
This may be a stupid question but I can't seem to figure this out.
I feel this might be a weird/stupid question, but here goes... In the question
Feel a bit silly asking this on here but I'm at a loose end
I still feel a bit unsafe about the topic and hope you folks can

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.