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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:19:49+00:00 2026-06-11T14:19:49+00:00

I have created a interface with buttons, but i don’t know how many buttons

  • 0

I have created a interface with buttons, but i don’t know how many buttons I need to create, so I have created them in java, with this code:

public void criaButton (String nome){

    TableLayout tl=(TableLayout)findViewById(R.id.tabBTALERT);    
    TableRow tr1 = new TableRow(this);
    tr1.setPadding(17, 15, 15, 5);
    final Button bt = new Button(this);
    bt.setText(nome);
    bt.setTextColor(Color.BLACK);
    bt.setBackgroundResource(R.drawable.botao);
    bt.setCompoundDrawablesWithIntrinsicBounds(R.drawable.envelope, 0, 0, 0);
    bt.setPadding(10, 20, 20, 20);
    bt.setId(id);
    tr1.addView(bt);
    tl.addView(tr1);
    bt.setOnClickListener( new View.OnClickListener() {
        public void onClick(View arg0) {

            idButton = bt.getId();
            nomeButton = (String) bt.getText();

            inicia ();
            Toast.makeText(Alerta.this, "Nome e ID : " + nomeButton + " " + idButton, Toast.LENGTH_SHORT).show();
        }
    });
}

with this method I can save the id and the name of every button I create. The problem is, these buttons have an image, and when I start another activity I have to change the image, if the message was read, not read, approved or rejected.

The question is, how can I give the id of the button to change the image and start again the activity with the changed image?? Is this possible?

  • 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-11T14:19:50+00:00Added an answer on June 11, 2026 at 2:19 pm

    Save the button ids in an array and then find the buttons by their ids and change their image to the desired one.

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

Sidebar

Related Questions

I have created 4 buttons via Interface Builder. I have an array which has
In Interface Builder components I have Gradient Button I would like to create this
I have created the simple web service. Code: [ServiceContract] public interface ITsdxService { [OperationContract]
Using xcode I have created an interface with several buttons, the problem I am
Basically I want to create 48 button outlets. I have created the buttons in
this is probably quite simple.. but I don't know what's the best practice here.
Hi, I am new to objective C.I have created two buttons using interface builder.Instead
I have created navigation controller via storyboard interface and I have added 4 buttons
I'm learning developing for android but i don't know how to create the UI
I have created an interface with ServiceContract on interface and OperationContract on all its

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.