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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:48:30+00:00 2026-06-16T14:48:30+00:00

Now i encountered problem while debugging my code,that the Buttons in my application is

  • 0

Now i encountered problem while debugging my code,that the Buttons in my application is not responding to click action.I kept break point on Click view method but on click view method is not responding.

What i am doing in on Click method is, if i clicked the first button then swapping the value with empty button value.But on click is not responding.

Here is my full code to check.

public class Play extends Activity implements OnClickListener
{   
private ArrayList<Integer> m_buildButtonsIDs;
private ArrayList<Integer> m_gameButtonsIDs;

public static Character UserWords;
public static Character RemainingWords;
public static Character OpenCard;

static ArrayList<Character> ShuffledCards = new ArrayList<Character>();
static ArrayList<Character> UserBuildWords = new ArrayList<Character>();
static ArrayList<Character> RemainingBuildWords = new ArrayList<Character>();
static ArrayList<Character> RemainingBuildWordsAfterShowCard = new ArrayList<Character>();
static ArrayList<Character> DroppedCards = new ArrayList<Character>();

static Stack<Character>UserDroppedCards = new Stack<Character>();

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.play);

    InitializeBoard();  
}

public void InitializeBoard() 
{      
  m_buildButtonsIDs = new ArrayList<Integer>();

  m_buildButtonsIDs.add(R.id.Button1);
  m_buildButtonsIDs.add(R.id.Button2);
  m_buildButtonsIDs.add(R.id.Button3);
  m_buildButtonsIDs.add(R.id.Button4);
  m_buildButtonsIDs.add(R.id.Button5);
  m_buildButtonsIDs.add(R.id.Button6);
  m_buildButtonsIDs.add(R.id.Button7);
  m_buildButtonsIDs.add(R.id.Button8);
  m_buildButtonsIDs.add(R.id.Button9);

  m_gameButtonsIDs = new ArrayList<Integer>();

  m_gameButtonsIDs.add(R.id.pickButton);
  m_gameButtonsIDs.add(R.id.showButton);
  m_gameButtonsIDs.add(R.id.emptyButton);

  String random = RandomAlphabetGenerator.Random();

  for(int i = 0;i<random.length();i++)
  {
    char randomcards = random.charAt(i);            

    ShuffledCards.add(randomcards);
  }

  for(int i = 0;i < 9;i++)
  { 
    UserWords = ShuffledCards.get(i);
    UserBuildWords.add(UserWords);

        if(i == 8)
        {
            for(int j = 9;j < 52;j++)
            {   
                RemainingWords = ShuffledCards.get(j);
                RemainingBuildWords.add(RemainingWords);
            }
        }
    }   

    OpenCard = RemainingBuildWords.get(0);

    DroppedCards.add(OpenCard);

    RemainingBuildWords.remove(0);
    RemainingBuildWordsAfterShowCard.addAll(RemainingBuildWords);

    FillUserBuildButtons(ShuffledCards);
    StackingDroppedButtons(DroppedCards);
    StackingPickButtons(RemainingBuildWordsAfterShowCard);
}   

private void FillUserBuildButtons(ArrayList<Character> shuffledCards)
{       
    for (int i=0 ; i<m_buildButtonsIDs.size() ; i++) 
    {
        Button BuildButton = (Button)findViewById(m_buildButtonsIDs.get(i));
        BuildButton.setText(UserBuildWords.get(i).toString());          
    }
}

private void StackingDroppedButtons(ArrayList<Character> droppedCards)
{       
    Button ShowButton = (Button)findViewById(m_gameButtonsIDs.get(1));
    ShowButton.setText(DroppedCards.get(0).toString());     
}

private void StackingPickButtons(ArrayList<Character> remainingBuildWordsAfterShowCard)
{       
    Button ShowButton = (Button)findViewById(m_gameButtonsIDs.get(0));
    ShowButton.setText(RemainingBuildWordsAfterShowCard.get(0).toString());     
}

public void onClick(View v)
{       
    CharSequence text;

    switch(v.getId())
    {
      case R.id.Button1:

          Button FirstButton = (Button)findViewById(m_buildButtonsIDs.get(0));
          text = FirstButton.getText().toString();
          FirstButton.setText(SwapValue(text)); 
          break;

      case R.id.emptyButton:              
          break;
    }   
}

private CharSequence SwapValue(CharSequence k) 
{
    CharSequence empty = null;

    Button EmptyButton = (Button)findViewById(m_buildButtonsIDs.get(0));
    empty = EmptyButton.getText().toString();
    EmptyButton.setText(k);

    return empty;
}           

}

Here is my xml code for checking:

<TableLayout
android:id="@+id/MainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginTop="50dp"
android:layout_marginLeft="115dp">

<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp" >

<Button
android:id="@+id/Button1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button3"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Dummy"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:clickable="false"
android:visibility="invisible" />

<Button
android:id="@+id/Button4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button5"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button6"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />
</LinearLayout>

<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp" 
android:layout_marginBottom="30dp">

<Button
android:id="@+id/Dummy2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:clickable="false"
android:visibility="invisible" />

<Button
android:id="@+id/Dummy3"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:clickable="false"
android:visibility="invisible" />

<Button
android:id="@+id/Button7"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button8"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp" />

<Button
android:id="@+id/Button9"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp"/>

<Button
android:id="@+id/Dummy4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:clickable="false"
android:visibility="invisible" />

<Button
android:id="@+id/Dummy5"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:clickable="false"
android:visibility="invisible" />

</LinearLayout>

<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp" 
android:layout_marginLeft="20dp">

<Button
android:id="@+id/pickButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp"/>

<Button
android:id="@+id/showButton" 
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/button_label"
android:textSize="15dp"/>

<Button
android:id="@+id/emptyButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/empty"
android:textSize="15dp" />

<Button
android:id="@+id/emptyButton1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text=""
android:textSize="15dp" />

<Button
android:id="@+id/dropButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/drop"
android:textSize="15dp"/>

<Button
android:id="@+id/declareButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="72dp"
android:text="@string/declare"
android:textSize="15dp"/>

</LinearLayout>
</TableLayout>
  • 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-16T14:48:31+00:00Added an answer on June 16, 2026 at 2:48 pm

    you should add an onClickListener to your Button :

    btn.setOnClickListener(Play.this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've encountered a problem while writing code in Delphi. Namely I can't get acces
while developing an Android application that uses Rickshaw to draw some charts, I encountered
I have encountered a problem twice now whereby a producer thread produces N work
I'm fighting with socket programming now and I've encountered a problem, which I don't
Now I try to developing an application related to Image processing, for that I
I have encountered a problem that I cannot quite figure out. Would be super
I've been using Google Chrome for a while now and I noticed that it
I'm new to the python programming language and I encountered a problem while doing
We've encountered a very odd problem with regards to local notifications firing while our
I've encountered a very annoying problem while working with Firefox MSAA (). I tried

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.