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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:06:03+00:00 2026-06-05T22:06:03+00:00

Here is the short version. I have a Bonus Activity that has 25 image

  • 0

Here is the short version. I have a Bonus Activity that has 25 image Views that are clickable. What I need is when one ImageView is clicked all of the others need to be set to enabled(false). I’d like to do this in a for loop. An example of what I have is below.
ANY SUGGESTIONS

    private ImageView img1;
    private ImageView img2;
    private ImageView img3;
    private ImageView img4;
    private ImageView img5;
    private ImageView img6;
    private ImageView img7;
    private ImageView img8;
    private ImageView img9;
    private ImageView img10;
    private ImageView[] imageview = {img1,img2,img3,img4,img5,img6,img7,img8,img9,img10};
    int i = 0; 
    int imgv =0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.bonus_layout); 


        img1 = (ImageView) findViewById(R.id.imageView1);
        img2 = (ImageView) findViewById(R.id.imageView2);
        img3 = (ImageView) findViewById(R.id.imageView3);
        img4 = (ImageView) findViewById(R.id.imageView4);
        img5 = (ImageView) findViewById(R.id.imageView5);
        img6 = (ImageView) findViewById(R.id.imageView6);
        img7 = (ImageView) findViewById(R.id.imageView7);
        img8 = (ImageView) findViewById(R.id.imageView8);
        img9 = (ImageView) findViewById(R.id.imageView9);
        img10 = (ImageView) findViewById(R.id.imageView10);


    img1.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
            if(rank[b]==0){

            for(i<25) imageview.get(i) setEnabled(false);
                             (i++); 



//This example offered get a force close  for(ImageView iv:imageview)iv.setEnabled(false);
                }
              }} });

Here Is The Corrected code that yall help me with

public class BonusActivity extends Activity implements View.OnClickListener   
{
    Integer rank[]=  {0,100,200,300,0,400,500,0};


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.bonus_layout);

     final ImageView img1 = (ImageView) findViewById(R.id.imageView1);
     final ImageView img2 = (ImageView) findViewById(R.id.imageView2);
     final ImageView img3 = (ImageView) findViewById(R.id.imageView3);
     final ImageView img4 = (ImageView) findViewById(R.id.imageView4);
     final ImageView img5 = (ImageView) findViewById(R.id.imageView5);
     final ImageView img6 = (ImageView) findViewById(R.id.imageView6);
     final ImageView img7 = (ImageView) findViewById(R.id.imageView7);
     final ImageView img8 = (ImageView) findViewById(R.id.imageView8);
     final ImageView img9 = (ImageView) findViewById(R.id.imageView9);
     final ImageView img10 = (ImageView) findViewById(R.id.imageView10);
     final ImageView[] imageview ={img1,img2,img3,img4,img5,img6,img7,img8,img9,img10};

    img1.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {

            if(rank[b]==0){
            img1.setImageResource(R.drawable.empty);

            for(int i = 0; i<imageview.length;i++)
            {imageview[i].setClickable(false);}
  • 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-05T22:06:04+00:00Added an answer on June 5, 2026 at 10:06 pm

    Initialize your ImageView Array in your onCreate(), and then just simply use the below code to disable[enable false] each of the ImageView

    for(int i = 0; i < imageview.length; i++)
    {
        imageview[i].setEnabled(false);    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The short version is that I have a protocol which has an optional parameter.
Short Version: I have 7 SSISDeploymentManifest files I need to run. Is there a
First question here: it is a very short yet fundamental thing in Java that
I have an XML file that is very long, but here is a shot
Short version: Why don't I have to coerce 60, and int, into a double,
To short version of this question is that I want to accomplish something along
Short version of what I want to accomplish : I have a foot pedal
Short Version For those who don't have the time to read my reasoning for
I have a radiobuttonlist with a selectedindexchanged event that updates a search function. One
Short version : I think I need help with properly using events in PowerShell

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.