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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:32:51+00:00 2026-06-12T04:32:51+00:00

When I open a certain class which extends ArrayAdapter there is something strange happening

  • 0

When I open a certain class which extends ArrayAdapter there is something strange happening when I go to another screen en hit the back button. I set that for certain values the background of the inflated xml file should be set to grey (200,200,200). But when I hit the back button now, everything is grey, altough it is displaying good when I just go there through the main screen (and not hitting the back button…) Class is looking like this:

Code of the override getView method:

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

    if (mView == null) {

        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        mView = vi.inflate(R.layout.levelselector_item, null);

    }

    TextView level = (TextView) mView.findViewById(R.id.tvLevel);
    TextView levelScore = (TextView) mView.findViewById(R.id.tvLevelScore);

    if (mView != null) {

        level.setText(Integer.toString(getItem(position).getLevel()));

        loadDataBase();
        int correctAnswers = myDbHelper.getCorrectAnswers(getItem(position).getLevel());

        int correctAnswersPrev = 0;
        int correctAnswersPrev = myDbHelper.getCorrectAnswersPrev(getItem(position).getLevel());

        String correct = Integer.toString(correctAnswers);

        levelScore.setText(correct + "/60");
        level.setTypeface(font);
        levelScore.setTypeface(font);

        if (correctAnswersPrev < 2 && !correct.equals("") ){
        mView.setBackgroundColor(Color.argb(200, 200, 200, 200));
        }

    }
    return mView;
}

private void loadDataBase() {
    // TODO Auto-generated method stub
    myDbHelper = new DataBaseHelper(C);
    try {
        myDbHelper.createDataBase();
    } catch (IOException ioe) {
        throw new Error("Unable to create database");
    }
    try {
        myDbHelper.openDataBase();
    } catch (SQLException sqle) {
        throw sqle;
    }
}

Grtz!

  • 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-12T04:32:52+00:00Added an answer on June 12, 2026 at 4:32 am

    If you are certain that correctAnswersPrev is less than two and correct is not empty, then you need to create a default color for the adapter’s view recycler:

    if (correctAnswersPrev < 2 && !correct.equals("") ){
        mView.setBackgroundColor(Color.argb(200, 200, 200, 200));
    }
    else {
        mView.setBackgroundColor(Color.argb(00, 200, 200, 200));
    }
    

    This explicitly returns the background color to transparent when it should not be gray.

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

Sidebar

Related Questions

I have a console application which can also open winform under certain conditions.Processing(its a
I found the code to open/close the div when I click a certain button.
I have a Utils class which shows UIAlertView when certain notifications are triggered. Is
I have a controller class which spawns a window when a certain condition occurs.
I am using jQuery, and wish to make certain links open in a new
At a certain time each day, I'd like my browser to pop open a
Is it possible to leave a ContextMenuStrip open after a selection/check of certain items?
I'm trying to watch a process and wait for a certain pattern, say: open
I'm working on a Qt/C++ open source project that uses MySQL databases. One class
I currently have an app which, when a button is pressed, and after a

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.