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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:57:42+00:00 2026-06-07T06:57:42+00:00

In my android application I have some fields like MyButton a; MyEditText b; MySpinner

  • 0

In my android application I have some fields like

MyButton a;
MyEditText b;
MySpinner c;
MyTextView d;

Each of these is like public class MyButton extends Button implements InfoExtract and

public interface InfoExtract{
    String getTheText();
}

Out of these fields (the user can change some of them), there is a UserProfile to be created like so:

public class ProfileUpdate {
    // The fields have to be string no matter what
    String firstName;
    String lastName;
    String dateOfBirth;
    String relationshipStatus
}

The execution flow is like that:

List<InfoExtract> uiElements = new ArrayList<InfoExtract>();
uiElements.add(a);
uiElements.add(b);
uiElements.add(c);
uiElements.add(d);
someButton.setOnClickListener(new SaveProfileListener(uiElements);

The SaveProfileListener more or less does this:

ProfileUpdate pup = new ProfileUpdate();
int i = 0;
pup.firstName = uiElements.get(i++).getTheText()
pup.lastName = uiElements.get(i++).getTheText();
pup.dateOfBirth = uiElements.get(i++).getTheText();
pup.relationshipStatus = uiElements.get(i++).getTheText();

Bad thing #1: If I want to add another fields its obviously much work.

Bad thing #2: The order of elements in the list is important.

Bad thing #3: I cannot easily manipulate the date format for dateOfBirth for example.

What i could have done but what is equally bad:

// Pass the listener what fields it should use.
someButton.setOnClickListener(new SaveProfileListener(a, b, c, d);

How to make this nice and clean?

  • 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-07T06:57:43+00:00Added an answer on June 7, 2026 at 6:57 am

    I ended up using a Map and a new Enum type for each field.

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

Sidebar

Related Questions

I have some text views in an linear layout in my android application. Next
i am having a small problem with my android application. I have some mp3
I have an android application in which I have to execute some tasks at
I have a application for android 2.3.3 where I am setting some custom titles
i'm building an android application which have a chat. in this chat i each
in my android application I have some buttons that launch the native browser to
i am building an android application but i have some questions about the memory
I am creating an Android application which will have some embedded music inside of
Well.. I have some ImageButtons in my Android application. I want them to display
Hi am developing android application. I have some small doubt of how to change

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.