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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:17:10+00:00 2026-05-28T04:17:10+00:00

i have an array which is populated in the spinner adapter. now i wanna

  • 0

i have an array which is populated in the spinner adapter.
now i wanna change the size of the array! is it possible?
help!
thank u
`public void classpopulate() {
if (PEP.getUser() == null) {
return;
}

    classdetails = masterDataManager.getClassSections(PEP.getUser()
            .getUsername(), getApplicationContext());
    spnrClass = (Spinner) findViewById(R.id.spnrClass);
    spnrSubject = (Spinner) findViewById(R.id.spnrSubject);
    classname = new String[classdetails.size() + 1];
    classname[0] = "SELECET CLASS";

    for (int i = 1; i < classdetails.size() + 1; i++) {

        classname[i] = classdetails.get(i - 1).getClass_name() + "  "
                + classdetails.get(i - 1).getSection_name().toString();

    }

    ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>(
            getApplicationContext(), R.layout.spinner_item_class,
            R.id.spinnerclasstxt, classname);
    spnrClass.setAdapter(adapterClasses);
    spnrClass.setSelection(0);

    spnrClass
            .setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> arg0, View arg1,
                        int pos, long arg3) {
                    // LinearLayout layoutSpinnersubj = (LinearLayout)
                    // findViewById(R.id.layout_spinner);
                    // RelativeLayout subject_Text
                    // =(RelativeLayout)findViewById(R.id.layoutsubjecttext);
                    int selectedindex = pos;
                    if (selectedindex == 0) {
                        spnrSubject.setVisibility(View.INVISIBLE);
                    } else {
                        spnrSubject.setVisibility(View.VISIBLE);
                        selectedClass = classdetails.get(selectedindex - 1);

                        subjectpopulate(selectedClass);
                    }
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {

                }

            });

`

  • 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-28T04:17:10+00:00Added an answer on May 28, 2026 at 4:17 am

    You can use the ArrayAdapter methods clear, add, insert and/or remove to manipulate the adapter’s data.

    EDIT: From your comments, it sounds like you are eventually going to need to write your own custom adapter (probably by extending BaseAdapter), particularly if you want to have disabled (separator) rows, etc. You will have much more control over what gets displayed and how it looks. Search the web for “android custom list adapter” to find lots of examples of how to write one. It’s not too difficult.

    Nevertheless, if you want to keep using an ArrayAdapter, here’s an example of removing the first element of the list (it assumes that the adapter has been saved in a member field adapter):

    adapter.remove(adapter.getItem(0));
    

    For more complicated changes (like loading a completely different set of data), you might do something like this:

    String[] newData = . . .
    adapter.setNotifyOnChange(false); // temporarily turn off auto-notification
    adapter.clear();
    adapter.addAll(newData);
    adapter.notifyDataSetChanged(); // notifies and turns auto-notifications back on
    

    It’s good practice to suspend auto-notification when you are making several changes in sequence.

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

Sidebar

Related Questions

If I have a static array which does not change after being populated. Multiple
I have a DefaultTableModel which is populated with an Object[][] array. Now I want
I have an application, which has a Spinner that I want populated with some
I have table view which is populated from an array grabbed from a url.
Hi i have an android spinner populated from and array that i want to
Hello I have question about android spinner I have spinner which is populated by
Hello I have question about android spinner I have spinner which is populated by
I have an array which populated by a cookie. The length differ each time.
I have a UITableView which is populated with an array of objects of type
I have a ListView which is populated from a string-array resource. I'm trying to

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.