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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:50:22+00:00 2026-05-26T16:50:22+00:00

I have a Spinner Control bind with data from Sqllite during the Page Load

  • 0

I have a Spinner Control bind with data from Sqllite during the Page Load as given below.

public void BindSpinner() {
        ArrayList<HashMap<String, String>> alist = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> map = new HashMap<String, String>();
        Cursor cursor;
        delivary_helper deliveryHelper;
        SimpleAdapter simpleAdapter;
        deliveryHelper = new delivary_helper(this);
        cursor = deliveryHelper.GetProblemCodes();
        cursor.moveToFirst();

        for (int i = 0; i < cursor.getCount(); i++) {
            map = new HashMap<String, String>();

            map.put("Deliv_Issue2_PKProblemCode",
                    cursor.getString(cursor.getColumnIndex("PKProblemCode")));
            map.put("Deliv_Issue2_ProblemCode",
                    cursor.getString(cursor.getColumnIndex("ProblemCode")));
            map.put("Deliv_Issue2_ProblemCodeDescription", cursor
                    .getString(cursor.getColumnIndex("ProblemCodeDescription")));
            map.put("Deliv_Issue2_VWReturn",
                    cursor.getString(cursor.getColumnIndex("VWReturn")));
            alist.add(map);
            cursor.moveToNext();
        }

        simpleAdapter = new SimpleAdapter(this, alist,
                R.layout.delivery_issue_2_spinner_row, new String[] {
                        "Deliv_Issue2_PKProblemCode",
                        "Deliv_Issue2_ProblemCode",
                        "Deliv_Issue2_ProblemCodeDescription",
                        "Deliv_Issue2_VWReturn" }, new int[] {
                        R.id.tvDelivIssue2PKProblemCode,
                        R.id.tvDelivIssue2ProblemCode,
                        R.id.tvDelivIssue2ProblemCodeDescription,
                        R.id.tvDelivIssue2VWReturn });
        delivery_line_problem.setAdapter(simpleAdapter);
    }

I have Saved the ID of the Selected item in the Sqllite database table.

The Problem is that when i return to the same Page after saving the Spinner control data and going throught the other pages,I am not able to get selected the saved data in the Spinner control.How can I make selected the item that i have saved and also need to fully bind the spinner with ohter data behind.

Will any one provide me a solution.

  • 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-26T16:50:22+00:00Added an answer on May 26, 2026 at 4:50 pm

    If I’m understanding you correctly, you should be able to just set an OnItemSelectedListener on your spinner. Whenever an item is selected, save it to an instance variable in your activity. That way you’ll always know the last item that was selected. So something like this:

    yourSpinner.setOnItemSelectedSpinner(new AdapterView.OnItemSelectedListener(){
       public void onItemSelected (AdapterView<?> parent, View view, int position, long id){
         lastItemSelected = id;
       }
       public  void onNothingSelected (AdapterView<?> parent){
         //do nothing here
       }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 spinner, each spinner's data loaded from database using AsyncTask i call
I have a Spinner that's populated using a cursor containing data from a database.
I have implemented an activity that retrieves data from a web service and display
I have been following the tutorial for adding spinner items to a spinner control
I have one spinner in which few values are there from strings.xml and I
I have setup Spinner with the layout below, and I wanted to get the
I have a form with a System.Windows.Forms.NumericUpDown control. Say that the range is from
I have a spinner widget and I want to populate some data when user
I have a spinner. Now I want to compare the variable from the spinner
I want to have a spinner at the top of page, and then generate

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.