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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:03:39+00:00 2026-06-12T13:03:39+00:00

This is my code. If I click 14 then in a spinner should be

  • 0

This is my code. If I click “14 ” then in a spinner should be set as a default value as 14, and if I changed “20” or some values like “16” it should set as a default value in a Spinner.

So selected value must be displayed in a Spinner.

 Spinner font=new Spinner(con);
 option= new String[] {"Select","14","16","18","20"};
 ArrayAdapter<String> adapter= new ArrayAdapter<String>(con,android.R.layout.simple_spinner_dropdown_item,option);
 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 font.setOnItemSelectedListener(new OnItemSelectedListener() {

 public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long id) {
 if(!(arg0).getSelectedItem().toString().trim().equalsIgnoreCase("Select"))
 size=Float.parseFloat((option[(arg0).getSelectedItemPosition()]).trim());
       }
 public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });
 font.setAdapter(adapter);
 int i;
 for( i=0;i<option.length;i++){

 if(option[i].toString().equalsIgnoreCase("14")){
  }
 else  {
 font.setSelection(i);
        }

     }
  • 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-12T13:03:40+00:00Added an answer on June 12, 2026 at 1:03 pm

    When you goto next screen and comeback then it automatically displays the last selected value by default (if your for loop code not exists here). if you goto previous screen from the spinner screen and come back then spinner will be created again and adapter is set again. so value selected last cannot be set. If still that is your requirement then save the value to shared preferences when selected. then after setting adapter, you get the value if already exists. In your code instead of checking equal condition with “14” you check it with shared preference saved value and call setSelection(i) in if loop

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

Sidebar

Related Questions

If you run this code and click on tab 2 and then back on
I have this code $(.delete2).click(function() { $('#load2').fadeIn(); } I have dynamically added item via
Here in this code: $('#doneItem').click(function(){ $(this).each(function(index){ var item = 'personal' + index; alert(item); localStorage.removeItem('personal'
This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();
This code works perfectly except when you click on a link, The page is
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
In button click event I am writing this code.(code behind).I know button click event
This code works anywhere else.. form load, button click, etc. But when I add
I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have this code: $('.user_info').click(function(){ var pos = $(this).offset(); rel_value = $(this).attr('rel'); $('#' +

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.