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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:00:09+00:00 2026-06-03T15:00:09+00:00

I have two ListViews, the second view items change according to what the first

  • 0

I have two ListViews, the second view items change according to what the first user chose in the first ListView

When at first the user choose an item from the first list, the second ListView loads without a problem… but when going back to the first ListView, selecting another item, the second ListView gives the Illegal State Exception…

and I have no idea when to notify the ListView about DataSetChanges because it doesn’t make sense to notify it before or after the setListAdapter!

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int mIndex = getIntent().getIntExtra("mIndex", 0);

    adapter = new mListAdapter(this, getItems(mIndex));

    setListAdapter(adapter);

}

Update:
I changed the adapter class and the problem disappeared… This is my old custom class that caused the error… Any idea what is wrong with it?

mListAdapter Class

public class mListAdapter extends BaseAdapter {

private static ArrayList<mItemsHolder> arrayList;

private LayoutInflater mInflater;

Context context;
int textSize;

public mListAdapter (Context m_context, ArrayList<mItemsHolder> results, int mTextSize) {
    arrayList = results;
    mInflater = LayoutInflater.from(m_context);
    context = m_context;
    textSize = mTextSize;

}

public int getCount() {
    return arrayList.size();
}

public Object getItem(int position) {
    return arrayList.get(position);
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.custom_row, null);
        holder = new ViewHolder();
        holder.mainItem = (TextView) convertView.findViewById(R.id.row_txt_main);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();         
    }

    Typeface typeFace=Typeface.createFromAsset(context.getAssets(),"fonts/verdana.ttf");
    holder.mainItem.setText(arrayList.get(position).getMainItem());
    holder.mainItem.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
    holder.mainItem.setTypeface(typeFace);
    return convertView;
}

static class ViewHolder {
    TextView mainItem;
}
}
  • 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-03T15:00:14+00:00Added an answer on June 3, 2026 at 3:00 pm

    I just removed “static” when declaring my ArrayList in

    private static ArrayList<mItemsHolder> arrayList;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two listviews, clicking an item on the first list view loads the
I have two listViews on the page. I select Item in the first one
I have a listview with several items that are created dynamically, each has two
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have two user controls on the same page. One contains a ListView that
I have two forms using a ListView component. In the first form it works
I have a WPF program with two listviews which display information from two different
I have two activities. In first I put a list of items with a
I have two Layouts, first is some custom layout, and the second is a
i want to create a Listview with two different Layouts. The first item should

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.