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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:30:03+00:00 2026-06-03T17:30:03+00:00

I have over 30 clickable imagebutton views that I want to create programatically instead

  • 0

I have over 30 clickable imagebutton views that I want to create programatically instead of using multiple xml files. Can someone please explain how I can do so? For each imagebutton, I need to:

  1. be able to name and set the ID of each view programatically, like R.drawable.button01, R.drawable.button02, etc. since I would need to refer back to them later with findViewById().

  2. each imagebutton is clickable and I have a button pressed down image for each button so I need to figure out how to assign the button press actions to each button dynamically instead of using a xml resource file for each.

Thanks in advance.

  • 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-03T17:30:07+00:00Added an answer on June 3, 2026 at 5:30 pm

    Take any of the layout as root like Linear or Relative initialize it ..

    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    ImageButton button =new ImageButton(context);
    layout.addView(layout);
    setContentView(layout);
    

    I hope this solves your problem.

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

Sidebar

Related Questions

I have a program that can have a lot of parameters (we have over
We all know the effects that lots of thrown exceptions can have over the
If I'm building an application that will have over 30 models, and I want
im planning to create a movie file that might have over 16,000 frames?i know
I have a div that I want to be clickable but I need a
I have over a million text files compressed into 40 zip files. I also
I have an UIImageView on my view. Certain parts of that image, I want
In Android 2.2, I want to display a few sprites and clickable animations over
I have some objects that are created/destroyed very often and that can exist in
I would like to create links that have icons included in the link. For

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.