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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:22:05+00:00 2026-06-06T13:22:05+00:00

I am using a list view and an adapter for loading a list,each list

  • 0

I am using a list view and an adapter for loading a list,each list item has a TextView,EditText and Image..I set the visibility of the arrow and the Edit text according to the position of the list row,everything works fine when I load the list for the first time…
But when I scroll through the list,visibility of the items keep changing…Kindly help me in this issue…The relevant codes has been attached…

<?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="wrap_content"
        android:orientation="horizontal"  android:background="#FFFFFF">
    <TextView android:layout_height="wrap_content"  android:layout_width="0dip"
            android:textSize="20dip" android:layout_weight="1"
            android:id="@+id/textview_add_lot_list" android:textColor="@android:color/black"
            android:paddingTop="10dip" android:paddingBottom="10dip"
            android:paddingLeft="10dip"/>
    <EditText android:layout_height="fill_parent" android:layout_width="0dip"
            android:layout_weight="1" android:id="@+id/et_add_lot_list"
            android:layout_gravity="center_vertical"/>
    <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content"
            android:id="@+id/imageview_arrow_add_lot_list" android:layout_gravity="center_vertical"
            android:visibility="invisible" android:src="@drawable/more_reviews_arrow"
            android:paddingRight="10dip"/>
</LinearLayout>

Java code activity…

final ArrayList<String> listItems       =   new ArrayList<String>();
        listItems.add("Parking name");
        listItems.add("Address");
        listItems.add("City");
        listItems.add("State");
        listItems.add("Zip");
        listItems.add("Phone");
        listItems.add("Web Address");
        listItems.add(" ");
        listItems.add("Parking Image");
        listItems.add(" ");
        listItems.add("Open Hours");
        listItems.add(" ");
        listItems.add("Web Reviews");

        final AddParkingLotAdapter adapter  =   new AddParkingLotAdapter(mAppContext,0,listItems);
        lv.setAdapter(adapter);

Java code…adapter

public class AddParkingLotAdapter extends ArrayAdapter<String> {
    private ArrayList<String> mStrings;
    private LayoutInflater mInflater;
    private AppContext mContext;

    private static int NON_EMPTY_ROW    =   1;                                                                                                          
    private static int EMPTY_ROW       =    0;

    public AddParkingLotAdapter(Context context, int resId, List<String> strings) {
        super(context, resId,strings);
        mStrings        =   (ArrayList<String>) strings;
        mContext        =   (AppContext) context;
        mInflater       =   LayoutInflater.from(context);
    }
    @Override
    public int getViewTypeCount() {
        return 2;                               
    }
    @Override
    public int getCount() {
        return mStrings.size();     
    }
    @Override
    public String getItem(int position) {
        return mStrings.get(position);
    }
    @Override
    public int getItemViewType(int position) {
        if(position==7||position==9||position==11){
            return EMPTY_ROW;
        }else{
            return NON_EMPTY_ROW;
        }
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView itemTextView   =   null;

        //different inflations for different type rows..
        if(getItemViewType(position) == EMPTY_ROW){
            if (convertView == null) {
                convertView         =   mInflater.inflate(R.layout.review_empty_row, null);
            }
        }else if(getItemViewType(position) == NON_EMPTY_ROW){
            if (convertView == null) {
                convertView     =   mInflater.inflate(R.layout.add_parkinglist_item, null);
            }
            itemTextView        =   (TextView) convertView.findViewById(R.id.textview_add_lot_list);
            itemTextView.setText(mStrings.get(position));
            if (position==3||position==8||position==10||position==12){
                ImageView itemImageView       =   (ImageView)convertView.findViewById(R.id.imageview_arrow_add_lot_list);
                itemImageView.setVisibility(View.VISIBLE);
                EditText editText             =   (EditText)convertView.findViewById(R.id.et_add_lot_list);
                editText.setVisibility(View.INVISIBLE);
            }
        }
        return convertView;
    }
}
  • 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-06T13:22:07+00:00Added an answer on June 6, 2026 at 1:22 pm

    In this code:

    if (position==3||position==8||position==10||position==12){
        ImageView itemImageView       =   (ImageView)convertView.findViewById(R.id.imageview_arrow_add_lot_list);
        itemImageView.setVisibility(View.VISIBLE);
        EditText editText             =   (EditText)convertView.findViewById(R.id.et_add_lot_list);
        editText.setVisibility(View.INVISIBLE);
    }
    

    you’ve got no else clause. That means that if position is 0,1,2,4,5 or 6 you don’t explicitly set the visibility of the views and so the visibility will be whatever it was set to when the views were recycled. If convertView is non-null, you always need to reset the visibility of any items whose visibility may be been modified earlier.

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

Sidebar

Related Questions

I have created a custom listview using adapter. Each row of the list view
I m using Fedor's lazy Loader Adapter for showing images on a list view.
I have a little issue with setting an image to a list view using
We have created custom listview by using the Base adapter. List view contains Text
In my list view inflator i have an image and a textview. When the
I have a list view of items, every item has a layout with three
I have an activity that has two tabs and a list view in each.
How to create a simple list view using only array adapter and getview. Without
I am Inflating the List view by using the Base adapter Inside the Listview
I need a little help with my custom list view adapter. I'm using the

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.