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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:28:25+00:00 2026-05-16T03:28:25+00:00

I have a listview with a custom arrayadapter that handles about 15 strings. The

  • 0

I have a listview with a custom arrayadapter that handles about 15 strings. The style of each row alternates (between labels and values for those labels–for example row 1 could be “email address” and row 2 would be the actual email address). I’m changing the style of each row to alternate like this in the arrayadapter’s getView() method. So if the item at the current position is a label, I’ll change the styling from the default row style (which is what the values have applied to them). When the listview first loads, the styling is perfect and just how I want it to be. If I scroll the list slowly up or down, it stays that way. However, if I scroll the list fast up and down, the styling of the value rows starts changing to that of the label ones until all of the rows have the styling of a label row. Does anyone know why this would be happening? I’ve used custom adapters on other listviews in the app with no problems like this.

Edit: Found out that it also changes all of the rows to the label styling on portrait->landscape orientation changes. Doesn’t do this on landscape->portrait changes. Below is the adapter I’m using. Am I missing something?

public class DetailsAdapter extends ArrayAdapter<String> {

private TextView text = null;
private String item = null;

public DetailsAdapter(Context context, int resource, int textViewResourceId, String[] objects) {
    super(context, resource, textViewResourceId, objects);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    text = (TextView) super.getView(position, convertView, parent);
    item = getItem(position);
    if (item.equals("Name") || item.equals("Mobile") || item.equals("Home") || item.equals("Email") || item.equals("Address")) {
        text.setBackgroundColor(0xFF575757);
        text.setTextSize(15);
        text.setTypeface(null, Typeface.BOLD);
        text.setPadding(8, 5, 0, 5);
    } else {
        text.setPadding(15, 15, 0, 15);
    }
    return text;
}

@Override
public boolean isEnabled(int position) {
    item = getItem(position);
    if (item.equals("Name") || item.equals("Mobile") || item.equals("Home") || item.equals("Email") || item.equals("Address")) {
        return false;
    } else {
        return true;
    }
}
}
  • 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-16T03:28:26+00:00Added an answer on May 16, 2026 at 3:28 am

    Android reuses views fairly aggressively, and it is quite possible that a view that was used as an email address row gets reused on a row that’s supposed to display a label, and vice-versa.

    As a result, you cannot rely on “default” values. Set your padding, typeface, text size and background color in all cases:

    if (item.equals("Name") || item.equals("Mobile") || item.equals("Home") || item.equals("Email") || item.equals("Address")) {
        text.setBackgroundColor(0xFF575757);
        text.setTextSize(15);
        text.setTypeface(null, Typeface.BOLD);
        text.setPadding(8, 5, 0, 5);
    } else {
        text.setBackgroundColor(DEFAULT_BACKGROUND);
        text.setTextSize(DEFAULT_TEXT_SIZE);
        text.setTypeface(null, DEFAULT_TYPEFACE);
        text.setPadding(15, 15, 0, 15);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that has a custom ArrayAdapter with a custom XML row.
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have a custom listview row that contains a number of textView components. Instead
I have created a custom ArrayAdapter that fills a ListView . The data in
I have used ListView and bounded my custom ArrayAdapter to it. Have setOnItemClickListener(...) bound
I have a listview with custom row having a textview and a clickable image
I have used custom listview and custom rating bar. If I add that custom
I have a ListView that I want to use with an ArrayAdapter to add
I have created custom listview in that have list of textview & list of

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.