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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:18:50+00:00 2026-06-05T18:18:50+00:00

I have checkBox and Spinner . If the checkbox is checked, then spinner should

  • 0

I have checkBox and Spinner. If the checkbox is checked, then spinner should call the database and get the values from there, otherwise default value.

My Problem is :
If CheckBox is checked, Spinner should be called. How to implement this?

My code is :

private HashMap<Integer,ReturnProduct> retrunTypes  =new HashMap<Integer, ReturnProduct>();

checkBox1=(CheckBox)findViewById(R.id.checkBox1);
  checkBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if(isChecked) {
            rtnStatus =true;
            retrunTypes = getReturnRason(); 
        }else {
            rtnStatus =false;
        }

    }
   });

Spinner:

     retrunTypes = getReturnRason();
    ArrayList<String> returnTypeList = new ArrayList<String>();
    for (Map.Entry<Integer, ReturnProduct> entry : retrunTypes.entrySet()) {
            ReturnProduct myProduct = entry.getValue();
            returnTypeList.add(myProduct.getDescription());
    }

    retuReason = (Spinner) findViewById(R.id.retuReason);
    reTypeAdapter = new ArrayAdapter<String>(SalesActivityGroup.group.getApplicationContext(),android.R.layout.simple_spinner_item, returnTypeList);
    reTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    retuReason.setAdapter(reTypeAdapter);
    retuReason.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view,int arg2, long arg3) {
            //selectedReType = parent.getSelectedItem().toString();
            selectedReTypeId= arg2;
            selectedReType = retrunTypes.get(selectedReTypeId).getReturnReason();

            //ReturnProduct rProduct = findReturnType(selectedReType);
            processingRequird = retrunTypes.get(selectedReTypeId).getProcessingRequired();
            selectedReTypeCode = selectedReType;
            selectedRetCategory =  retrunTypes.get(selectedReTypeId).getReturnCategory();
        }
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });


 private HashMap<Integer,ReturnProduct> getReturnRason(){
    DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
    HashMap<Integer,ReturnProduct> returnType = new HashMap<Integer, ReturnProduct>();
    try {
        dbAdapter.openDataBase();
        String  query ="";
        if(rtnStatus) {
            query = "SELECT rs.ReturnReasonCode,rs.ReturnType,rs.Description,rt.ProcessingRequired,rt.ReturnCategory " +
                    " FROM WMReturnReason rs,WMReturnType rt" +
                    " WHERE rs.ReturnType =rt.ReturnType AND rs.BusinessUnit=? AND Status ='1' AND  rt.ProcessingRequired ='1' ";
        }else {
            query = "SELECT rs.ReturnReasonCode,rs.ReturnType,rs.Description,rt.ProcessingRequired,rt.ReturnCategory " +
                    " FROM WMReturnReason rs,WMReturnType rt" +
                    " WHERE rs.ReturnType =rt.ReturnType AND rs.BusinessUnit=? AND Status ='1' ";
        }

        String[] d = new String[]{strBusinessUnit};
        ArrayList<?> stringList = dbAdapter.selectRecordsFromDBList(query, d);

        dbAdapter.close();
        //System.out.println("===getReturnType=="+stringList.size());
        if(stringList.size() > 0){
            for (int i = 0; i < stringList.size(); i++) {
                ArrayList<?> arrayList = (ArrayList<?>) stringList.get(i);
                ArrayList<?> list = arrayList;
                ReturnProduct returnProduct = new ReturnProduct();
                returnProduct.setReturnReason((String) list.get(0));
                returnProduct.setReturnType((String) list.get(1));
                returnProduct.setDescription((String) list.get(2));

                returnProduct.setProcessingRequired((String) list.get(3));
                returnProduct.setReturnCategory((String) list.get(4));

                returnType.put(i, returnProduct);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return returnType;
 }
  • 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-05T18:18:52+00:00Added an answer on June 5, 2026 at 6:18 pm

    You can use spinner.setSelection(pos) inside the setOnCheckedChangeListener. I can see that you have rolled out your own method to get the value from the database. Now based on the value returned just make the selection of your spinner.

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

Sidebar

Related Questions

I have a checkbox who's checked value is bound to a binding source which
I have a checkbox in GridViewColumn which i use for show/change database value. The
I have a checkbox that if checked stores the value testing to the field
We have a checkbox that is initially disabled and checked. It is then enabled
I have a checkbox column in my JqGrid which get loaded from DB, so
I have a checkbox in repeater control. on changing it's bit value, it should
I have a checkbox which in some cases may be disabled and checked using
I have to copy the text from one text box to another using checkbox
I have a checkbox with a Checked property and a Listbox with an Enabled
I have a checkbox column bound to a dependency property. When editing the checked

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.