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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:00:51+00:00 2026-05-18T00:00:51+00:00

I am searching a way to do this : public class SimpleText_SpinnerAdapter extends ArrayAdapter<Enum1>

  • 0

I am searching a way to do this :

public class SimpleText_SpinnerAdapter extends ArrayAdapter<Enum1> {
   many lines of code with a one moment : String val = oneEnum1val_inparam.getlabel();
}

public class SimpleText_SpinnerAdapter extends ArrayAdapter<Enum2> {
   exactly the same code than previously, but for Enum2
}

public class SimpleText_SpinnerAdapter extends ArrayAdapter<Enum3> {
   exactly the same code than previously, but for Enum3
}

This is made to have 3 adapters for 3 spinners, that contains values from 3 differents Enums constructed exactly the same way but with different values.

Of course, each enum type has a getLabel() method.

I’d like to find a way to do this without needing to copy-paste 3 times the same code for each adapter. A sort of generic one, that could be referenced by 3 specialized one.

I don’t find the solution.
Could you help me to do this ?

Or if you have somthing more efficient…

Oliver

  • 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-18T00:00:52+00:00Added an answer on May 18, 2026 at 12:00 am

    How about:

    public class SimpleText_SpinnerAdapter<T extends Enum<T> & ProvidesLabel>
        extends ArrayAdapter<T>
    {
        // implementation
    }
    
    
    
    public enum Enum1 implements ProvidesLabel
    {
            Entry1("label 1"),
            Entry2("label 2");
    
        private final String label;
    
        private Enum1(String label)
        {
            this.label = label;
        }
    
        @Override 
        public String getLabel()
        {
            return this.label;
        }
    }
    
    public interface ProvidesLabel
    {
        String getLabel();
    }
    

    Instantiate class with (nm the constructor):

     SimpleText_SpinnerAdapter<Enum1> enum1 =
            new SimpleText_SpinnerAdapter<Enum1>(context, textViewResourceId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am searching for a way to compress JavaScript code for the iPhone. Is
I have been searching for a way to insert linebreaks in my code for
I've been unsuccessfully searching for a way to install make utility on my CentOS
Introduction I've always been searching for a way to make Visual Studio draw a
I'm a NetBeans 6.5 user and am searching for a way of generating a
Im searching for the best way to mantain combo box values within a Mysql
I have been searching high and low for a way to get my silverlight
Is there a simple way to support wildcards (*) when searching strings - without
I've tried searching but couldn't come up with a defined way on how to
Searching for some sample code for converting a point in WGS84 coordinate system to

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.