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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:53:08+00:00 2026-05-26T14:53:08+00:00

My View <Button android:id=@+id/button1 android:text=Text 1 android:layout_height=wrap_content android:layout_width=fill_parent></Button> <Button android:id=@+id/button2 android:text=Text 2 android:layout_height=wrap_content android:layout_width=fill_parent></Button>

  • 0

My View

<Button android:id="@+id/button1" android:text="Text 1"
android:layout_height="wrap_content"
                android:layout_width="fill_parent"></Button>

        <Button android:id="@+id/button2" android:text="Text 2"
android:layout_height="wrap_content"
                android:layout_width="fill_parent"></Button>

        <Button android:id="@+id/button3" android:text="Text 3"
android:layout_height="wrap_content"
                android:layout_width="fill_parent"></Button>

        <Button android:id="@+id/button4" android:text="Text 4"
android:layout_height="wrap_content"
                android:layout_width="fill_parent"></Button> 

I have an undefined amount of buttons and need get you text in a touch event.

How i do it?

Tnks a lot.

EDIT:

Thanks for all, this is result of the your Answers => https://play.google.com/store/apps/details?id=br.com.redrails.torpedos
My App 😀

  • 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-26T14:53:09+00:00Added an answer on May 26, 2026 at 2:53 pm

    If you name all of your buttons “button1, button2, button3…” you can do this:

    for(int i = 1; i <= buttonCount; i++) {
        int id = getResources().getIdentifier("button" + i, "id", getPackageName() );
        findViewById(id).setOnClickListener(this);
    }
    

    Where buttonCount is the amount of buttons you have. This method would be placed in onCreate().

    Then for your onClick:

    public void onClick(View v) {
        if (v instanceof TextView) {
            CharSequence text = ((TextView) v).getText();
            // Do fun stuff with text
        }
    }
    

    Your Activity will need to implement OnClickListener

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

Sidebar

Related Questions

I've got the following node in my XML layout: <com.x.y.view.TagLayout android:id=@+id/TagLayout android:layout_width=fill_parent android:layout_height=170dip />
xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/bkgrnd> <ScrollView android:id=@+id/ScrollView01 android:layout_width=fill_parent android:layout_height=fill_parent android:isScrollContainer=true android:scrollbars=vertical android:scrollbarAlwaysDrawVerticalTrack=true> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a custom list view which contains two text views and on button.
I want to show a button at the end of an Android list view.
I have a view with a button at the bottom of the portrait screen,
I have a view with a button and three UITextFields. The view's background is
We have place a button on a view. When we press it, nothing happens.
I have a button in a view which refuses to work. I've got in
I have a view with which I have a button calling the following method.
I have form area in my view. If I click button A , I

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.