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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:22:05+00:00 2026-05-23T16:22:05+00:00

I have spent literally two days trying to sort this issue. If anyone could

  • 0

I have spent literally two days trying to sort this issue. If anyone could help I would be massively appreciative.

What I’m trying to achieve:

Have a ListView, whereby the player can add new entries (players), through a text field (for the player name), and then a submit button. In each field of the ListView, I display the player name, and then two ImageButtons. One with a male symbol, and one with a female symbol. The male symbol is toggled by default, and the user can set the player as being male or female by toggling either the male button or the female button. Finally, once the user moves onto the next screen (a new activity), the application will save the player names and the attached sex to some form of storage and proceed to the next activity.

What I have achieved:

I have a simple array adapter, which upon the player adding a new player name to the list, I run the notifyDataSetChanged() on it. The adapter also is set to use a custom row layout file. Inside the layout file, it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content">
    <RelativeLayout android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:id="@+id/relativeLayout1" android:layout_marginTop="5dp">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/playerName"
            android:layout_centerVertical="true" android:text="Derp" android:textStyle="bold" android:layout_marginLeft="5dp" android:textSize="22dp" android:textColor="@color/male_blue"></TextView>
        <ImageButton android:layout_height="60dp"
            android:layout_width="60dp" android:onClick="maleClickHandler"
            android:src="@drawable/male_icon_settings" android:id="@+id/buttonA" android:layout_alignParentRight="true" android:layout_marginRight="65dp"></ImageButton>
        <ImageButton android:onClick="femaleClickHandler"
            android:layout_height="60dp" android:layout_width="60dp" android:id="@+id/buttonB"
            android:layout_alignParentRight="true" android:layout_marginRight="5dp" android:src="@drawable/female_icon_settings"></ImageButton>
    </RelativeLayout>
</LinearLayout>

The two buttons on each row reference to methods in the class file. Here is my code for this:

public void maleClickHandler(View v) {

        RelativeLayout vwParentRow = (RelativeLayout) v.getParent();
        ImageButton maleButton = (ImageButton) vwParentRow.getChildAt(1);
        maleButton.setImageDrawable(getResources().getDrawable(
                R.drawable.male_icon_selected));
        vwParentRow.refreshDrawableState();
    }

    public void femaleClickHandler(View v) {

        RelativeLayout vwParentRow = (RelativeLayout) v.getParent();
        ImageButton femaleButton = (ImageButton) vwParentRow.getChildAt(2);
        femaleButton.setImageDrawable(getResources().getDrawable(
                R.drawable.female_icon_selected));
        vwParentRow.refreshDrawableState();
    }

I haven’t yet implemented any inter-connectivity between these two buttons, to allow only one to be active at a time, or to even untoggle one, since I think I might be taking the wrong approach entirely.

The problem:

Upon adding new entries to the list, AFTER toggling one and/or the other male/female buttons, things get really buggy, and the male/female toggled icon might move as it should, along with the attached player string, or more likely, those toggled will stay on that first row (array position 0 of the list), or even move into the second list position, AND copy themselves as being toggled onto the row above.

How you can help…?

I have attached an image below of my screen, from the emulator, to help illustrate my points
Screenshot!

I think that I might need to use some form of custom adapter; I have done so much reading around on the subject, but I can’t find anything relevant to what I am trying to achieve, so if you could point me in the right direction, or even try and put together the most basic solution to this type of problem, I would be very grateful.

Finally, when I get this working, which form of storage would be best for storing player names, and their sex? I would like the user to be able to keep the player list after they quit the application and restarted it.

Thanks for any help! 🙂

  • 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-23T16:22:06+00:00Added an answer on May 23, 2026 at 4:22 pm

    You will need to use a Custom Adapter, which in itself should be able to track the male/female flag for each of it’s entries.

    Your method will not work since the state of the buttons are managed by the getView method of the adapter. Even if you change them by digging through the children, the next time when the getView method is called, it’s going to mess up things.

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

Sidebar

Related Questions

I have literally spent hours trying to fix this but cant! Like the title
I have literally spent days searching for a solution to this problem. PHP's mkdir()
I have spent more time than i care to mention trying to sort this
I have spent three days trying to find the solution to this problem to
I have spent the past three days researching this... but Im still stuck. I
I have spent(wasted) the past two hours googling for a solution. Please help. I
I have spent two day trying to figure it out. I have implemented two
I have spent all day trying to solve this with no satisfying results. I
I have spent this afternoon trying to solve this question: How can I check
I have literally spent hours with JQuery trying to extract a piece of text

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.