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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:43:02+00:00 2026-06-16T05:43:02+00:00

I have a dialog setup that has two spinners connected to a cursor. I

  • 0

I have a dialog setup that has two spinners connected to a cursor. I have worked through a couple of problems with the help of this site, but I can not seem to get past this point. Everything I find are things I have already tried.
The problem is that when I click on a spinner selection or click Submit to exit the dialog, the spinner value is not the value it should be. I am getting the package name with some code. I am trying to get the string from the spinner with .getSelectedItem().toString();
I currently have the code set up to use onItemSelected, but before that I tried to use the getItemSelected once Submit was clicked. Neither seem to work.

Here is the code for this section.
At the end the values are going into a textview. The value shown is “android.database.sqlite.sqliteCursor@414175e0”

Any ideas?

 private void transfer() {
     dialog = new Dialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth);
     dialog.setContentView(R.layout.transfer_dialog);
     dialog.setTitle(R.string.transfer_accounts);
     Button btnCancel = (Button)dialog.findViewById(R.id.btnCancel);
     Button btnSubmit = (Button)dialog.findViewById(R.id.btnSubmit);

     Cursor load_spinner = mDbHelper.spinnerAccounts();
     startManagingCursor(load_spinner);

     String[] columns = new String[] { RegisterDbAdapter.ACCOUNTS_ACCOUNT };
     int[] to = new int[] { android.R.id.text1 };

     SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, load_spinner, columns, to);
     mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
     spinnerFrom = (Spinner)dialog.findViewById(R.id.spinnerFrom);
     spinnerTo = (Spinner)dialog.findViewById(R.id.spinnerTo);
     spinnerFrom.setAdapter(mAdapter);
     spinnerTo.setAdapter(mAdapter);
     dialog.show();

     spinnerFrom.setOnItemSelectedListener(new OnItemSelectedListener(){
         public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
             fromAccount = parent.getSelectedItem().toString();
         }
         public void onNothingSelected(AdapterView<?> arg0) {
             // TODO Auto-generated method stub
         }
        }); 
     spinnerTo.setOnItemSelectedListener(new OnItemSelectedListener(){
         public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
             toAccount = parent.getSelectedItem().toString();
         }
         public void onNothingSelected(AdapterView<?> arg0) {
             // TODO Auto-generated method stub
         }
        });
     btnCancel.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                 dialog.dismiss(); 
            }
          });

     btnSubmit.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                 tvFrom.setText(fromAccount);
                 tvTo.setText(toAccount);
                 dialog.dismiss();
            }
          });

 }
  • 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-16T05:43:04+00:00Added an answer on June 16, 2026 at 5:43 am

    So I finally got it to work. Thanks for the suggestions, I really do appreciate them, but they didn’t work for me. I am not sure why the code will not return the value, since the way I tried it supposedly works for others.
    Anyway, I found a way to get my values by using ‘Long arg3’. Since it holds the rowId of the value in the table, I used that to return the selection in the spinner. I am posting the code for this below.
    Thanks again.

    The code from the selected spinner:

      spinnerFrom.setOnItemSelectedListener(new OnItemSelectedListener(){
             public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                 getAccountName(arg3);
                 fromAccount = returnAccount;
                 }
    
            public void onNothingSelected(AdapterView<?> arg0) {
                 // TODO Auto-generated method stub
             }
            });
    

    And here is the method I wrote to return the value I wanted. I put it a separate method because it is getting used from multiple spinners. The code:

     private void getAccountName(long arg3) {
         if (returnAccount != null){
             returnAccount = null;
         }
            RegisterDbAdapter tAdaptor = new RegisterDbAdapter(this);
            tAdaptor.open();
            Cursor tCursor = tAdaptor.fetchAccount(arg3);
            startManagingCursor(tCursor);
            returnAccount = tCursor.getString(1);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple little dialog that lets user setup a time block. The
I have two servers with virtually identical setups (the second that is working has
I have a Maven project that has always worked fine in Netbeans, but upgrading
I have visual studio setup project with a custom RadioButtons dialog. How do I
I have click events set up like this: $('.dialogLink') .click(function () { dialog(this); return
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have a dialog preference with a button on it that I want to
I have a dialog with this content: <RelativeLayout android:layout_width=wrap_content android:layout_height=wrap_content > <ScrollView android:layout_width=fill_parent android:layout_height=wrap_content
I have a dialog that I want to place within another dialog and position
I have a dialog box with controls that is popped up and when a

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.