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

  • Home
  • SEARCH
  • 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 8323109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:36:58+00:00 2026-06-08T23:36:58+00:00

i have a strange problem .i am using a spinner on selection of its

  • 0

i have a strange problem .i am using a spinner on selection of its items i am opening a popup window but problem is that first time when any item is selected popup window opens but if that item is again selected popup does’nt open until any other item is selected before that item is selected again?? what should i do ?? plss help below is my code

      @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position,
            long id) {
        // TODO Auto-generated method stub
        switch (position) {
        case 0:

            break;
        case 1:
            pool_type_value=0;
            option_selected=2;
            calculation();
            break;

        case 2:
            pool_type_value=1;
            option_selected=2;
            System.out.println("pop up case 2");
            openPopupWindow(pool_legend);


            break;

        case 3:
            pool_type_value=2;
            option_selected=2;
            openPopupWindow(pool_legend);


            break;
        case 4:
            pool_type_value=0;
            option_selected=1;
            calculation();
            break;


        default:
            break;
        }

    }

          private void openPopupWindow(Spinner spinner) {
        // TODO Auto-generated method stub
        int h = 0;
        View popupView = null;
         Button btnDismiss = null;
        LayoutInflater layoutInflater 
         = (LayoutInflater)getBaseContext()
          .getSystemService(LAYOUT_INFLATER_SERVICE); 
         System.out.println("pop up ");
        if(width>240 && height>320)
          {
            h=350;

          }
        else if(width<=240 && height<=320){
            h=200;
        }
        if(pool_type_value==1){
         popupView = layoutInflater.inflate(R.layout.popup_rectangle_extension, null);
         btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
         ed_width_single_extension=(EditText)popupView.findViewById(R.id.editText_singleextension_width);
         ed_length_single_extension=(EditText)popupView.findViewById(R.id.editText_singleextension_lenght);

         System.out.println("pop up 1");
         if(!hashmap.get("single_width").equals("0")){
             ed_width_single_extension.setText(""+hashmap.get("single_width"));
             }
            if(!hashmap.get("single_length").equals("0")){
             ed_length_single_extension.setText(""+hashmap.get("single_length"));
             }

        }else if(pool_type_value==2){
         popupView = layoutInflater.inflate(R.layout.popup_rectangle_plus_extension, null);
         System.out.println("pop up 2");
         btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
        }
                 popupWindow = new PopupWindow(popupView, LayoutParams.FILL_PARENT,h);
                 popupWindow.setTouchable(true);
                 popupWindow.setFocusable(true);

                 btnDismiss.setOnClickListener(new Button.OnClickListener(){

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        hashmap.put("single_width", ed_width_single_extension.getText().toString());
                        hashmap.put("single_length", ed_length_single_extension.getText().toString());
                        calculation();

                        popupWindow.dismiss();
                        // setDatabase();
                    }



});



                popupWindow.showAtLocation( spinner, Gravity.CENTER, 0, 10);


    }
  • 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-08T23:37:01+00:00Added an answer on June 8, 2026 at 11:37 pm

    Try this

    public class NoDefaultSpinner extends Spinner {
    
        private int lastSelected = 0;
        private static Method s_pSelectionChangedMethod = null;
    
    
        static {        
            try {
                Class noparams[] = {};
                Class targetClass = AdapterView.class;
    
                s_pSelectionChangedMethod = targetClass.getDeclaredMethod("selectionChanged", noparams);            
                if (s_pSelectionChangedMethod != null) {
                    s_pSelectionChangedMethod.setAccessible(true);              
                }
    
            } catch( Exception e ) {
                Log.e("Custom spinner, reflection bug:", e.getMessage());
                throw new RuntimeException(e);
            }
        }
    
        public NoDefaultSpinner(Context context) {
            super(context);
        }
    
        public NoDefaultSpinner(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public NoDefaultSpinner(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public void testReflectionForSelectionChanged() {
            try {
                Class noparams[] = {};          
                s_pSelectionChangedMethod.invoke(this, noparams);
            } catch (Exception e) {
                Log.e("Custom spinner, reflection bug: ", e.getMessage());
                e.printStackTrace();                
            }
        } 
    
    
    
    
        @Override
        public void onClick(DialogInterface dialog, int which) {    
            super.onClick(dialog, which);
                if(lastSelected == which)
                    testReflectionForSelectionChanged();
    
                lastSelected = which;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem. I am using the null layout for a window
I have a strange problem when using Entity Framework code first. When I return
I have a strange problem when deleteting records using linq, my suspicion is that
I have a strange JavaScript problem using window.location.href , which apparently only affects Firefox
i have a strange problem only in Chrome using an iframe but working in
I have an strange problem using two borders. I use them to display video
I have a very strange problem with using geometry shaders. I made a very
I do have a strange focus problem when using a JComboBox inside an embedded
I have strange problem with receiving data from socket. On client im using air
I have a strange problem with lxml when using the deployed version of my

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.