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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:07:38+00:00 2026-05-31T16:07:38+00:00

This is my code listview =(ListView) findViewById(R.id.lv1); ArrayList<SClass> Monday = new ArrayList<SClass>(); SClass s1=new

  • 0

This is my code

listview =(ListView) findViewById(R.id.lv1);


    ArrayList<SClass> Monday = new ArrayList<SClass>();

    SClass s1=new SClass();
    s1.sName="samp";
    s1.salary=1000;
    Monday.add(s1);
    temp=Monday;
    adapter = new CustomAdap(this, temp);
    listview.setAdapter(adapter);

The above code works fine.But when i change my code to this

    listview =(ListView) findViewById(R.id.lv1);


    adapter = new CustomAdap(this, temp);

    SClass s1=new SClass();
    s1.sName="samp";
    s1.salary=1000;
    Monday.add(s1);
    temp=Monday;

    listview.setAdapter(adapter);
    adapter.notifyDataSetChanged();

Listview does not show anything.what is the problem?

  • 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-31T16:07:39+00:00Added an answer on May 31, 2026 at 4:07 pm

    It looks like you’re changing the collection that you initialized adapter with. I would change your code in this way:

    // initial setup
    listview =(ListView) findViewById(R.id.lv1);
    ArrayList<SClass> Monday = new ArrayList<SClass>();
    adapter = new CustomAdap(this, Monday);
    listview.setAdapter(adapter);
    
    // change your model Monday here, since it is what the adapter is observing
    SClass s1=new SubjectClass();
    s1.sName="samp";
    s1.salary=1000;
    Monday.add(s1);
    
    // notify the list that the underlying model has changed
    adapter.notifyDataSetChanged();
    

    Note that if your CustomAdap was a subclass of ArrayAdapter, you could also have done

    // change your array adapter here
    SClass s1=new SubjectClass();
    s1.sName="samp";
    s1.salary=1000;
    adapter.add(s1);
    
    // notify the list that the underlying model has changed
    adapter.notifyDataSetChanged();
    

    EDIT: I understand more what you want to do now thanks to your comment. You’ll probably want to have the adapter replace its contents with that your different ArrayLists then. I would make your CustomAdap be a subclass of ArrayAdapter.

    Then you can utilize it this way:

    // replace the array adapters contents with the ArrayList corresponding to the day
    adapter.clear();
    adapter.addAll(MONDAY);
    
    // notify the list that the underlying model has changed
    adapter.notifyDataSetChanged();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the below code. listView = (ListView) findViewById(R.id.SkiiplistListView); listView.setOnItemClickListener(new OnItemClickListener() { @Override
ListView menuList = (ListView) findViewById(R.id.ListView_Menu); String[] items = {getResources().getString(R.string.menu_item_NxtInc)}; ArrayAdapter<String> adapt = new ArrayAdapter<String>(this,R.layout.menu_item,items);
how to see items that i pick on ListView ? i have this code:
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
I cant be able to show my data into a listview using this code
I have list of items with check boxes using this code: ProcessList = (ListView)
I have this code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView lv =
final ListView lv= (ListView)findViewById(R.id.list); String[] from = new String[] {a, b,c}; int[] to =
I wanted to generate a list view using below code. But after running this

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.