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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:56:43+00:00 2026-06-14T22:56:43+00:00

So my idea is to have a one list than have another list inside

  • 0

So my idea is to have a one list than have another list inside of it. The android grouping is not the solution I’m looking for. I don’t want them grouped.

The problem im having with memory leaks and all sorts of crazyness. Like the adapter iterating through the list multiple times. Below is my Adapter.

public class LotteryAdapter extends ArrayAdapter<LotteryBall> {

Context context;

public LotteryAdapter(Context context, int resourceId,
        List<LotteryBall> items) {
    super(context, resourceId, items);
    this.context = context;
}

/*private view holder class*/
private class ViewHolder {
    LinearLayout ballpanel;
    LinearLayout jackpotpanel;
    TextView txtTitle;
    TextView txtBall;
    TextView txtJackpot;

}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    LotteryBall rowItem = getItem(position);
    LayoutInflater mInflater = (LayoutInflater) context
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.mainrow, null);           
        convertView.setBackgroundResource(R.layout.greenbackground);    
        holder = new ViewHolder();     
        holder.txtTitle= (TextView) convertView.findViewById(R.id.LotteryTitle);           
        holder.ballpanel = (LinearLayout) convertView.findViewById(R.id.balllayout);
        holder.jackpotpanel = (LinearLayout) convertView.findViewById(R.id.jackpotlayout);
        convertView.setTag(holder);
    } else
        holder = (ViewHolder) convertView.getTag();

    holder.txtTitle.setText(rowItem.title);
    for(int i = 0;i < rowItem.balls.size();i++) 
      {
        Ball ball = rowItem.balls.get(i);
        if(ball != null){
            TextView tv = new TextView(context);  //<--problem with the context its causing the adapter to go crazy 
            tv.setText(ball.number);
            tv.setTextColor(Color.BLACK);
            tv.setBackgroundResource(R.drawable.yellowball);
            holder.ballpanel.addView(tv);

        }
      }
    //if jackpot
    TextView tvjackpot = new TextView(context);
    tvjackpot.setText("Current Jackpot: " + rowItem.amount);
    TextView tvnextdrawing = new TextView(context);
    tvjackpot.setText("Next Drawing: " + rowItem.nextdrawing);
    TextView tvpreviousjackpot = new TextView(context);
    tvjackpot.setText("Previous Jackpot: " + rowItem.lastamount);

    View ruler = new View(context); 
    ruler.setBackgroundColor(Color.WHITE);
    holder.jackpotpanel.addView(tvjackpot);
    holder.jackpotpanel.addView(ruler);
    holder.jackpotpanel.addView(tvnextdrawing);
    //holder.ballpanel.addView(ruler);
    holder.jackpotpanel.addView(tvpreviousjackpot);
    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-14T22:56:45+00:00Added an answer on June 14, 2026 at 10:56 pm

    Rewrite

    It looks like you are creating new TextView balls regardless of the existing ones. You should see how many currently exist then add or remove the difference:

    // Loop through the existing balls to update their text
    
    if(holder.ballpanel.getChildCount() > rowItem.balls.size()) {
        // Remove extra balls
    }
    else if(holder.ballpanel.getChildCount() < rowItem.balls.size()) {
        // Add new balls
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of items I want to buy. The items are offered
I have an advent/christmas calendar. Everyday is another picture with one more door opened.
I have list of products which have EditText in TableLayout . I want Keyboard
I have two tables. One contains a list of products with the primary key
I have a list view that show a list of items...well not all of
See Down farther: I have a list I converted to a very very long
Background: I have one Access database (.mdb) file, with half a dozen tables in
This is a question related to another one I asked that was specific to
I am creating a database table that'll have a list of all Tags available
I have the following LINQ code. public List<IGrouping<Guid, ProfileImage>> GetAllUser() { return _profileImageRepository.QueryProfileImage() .GroupBy(g

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.