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

  • Home
  • SEARCH
  • 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 7537975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:59:31+00:00 2026-05-30T06:59:31+00:00

I am making small bubble words game where there will be many bubble(Imageview) on

  • 0

I am making small bubble words game where there will be many bubble(Imageview) on the screen. Now there will be 15 bubbles already placed on the levelScreen…There will be three levels… Say first Level with its bg and its 15 objects in one layout level.xml
This is my xml for level1

    <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/gmw_01"
 android:onClick="onClick"
 android:layout_height="wrap_content" 
android:layout_width="wrap_content"
 android:id="@+id/relativeLayout1" >
 <ImageView 
android:onClick="objectClick" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:id="@+id/imageView1"
 android:src="@drawable/bb01" 
android:layout_marginLeft="998dp" 
android:layout_marginTop="593dp" 
android:layout_alignParentTop="true"
 android:layout_alignParentLeft="true"/>
 <ImageView 
android:onClick="objectClick"
 android:layout_height="wrap_content" 
android:layout_width="wrap_content"
 android:id="@+id/imageView2"
 android:src="@drawable/bb02"
 android:layout_marginLeft="20dp" 
android:layout_marginTop="39dp" 
android:layout_alignParentTop="true"
 android:layout_alignParentLeft="true"/>
 <ImageView
 android:onClick="objectClick"
 android:layout_height="wrap_content" 
android:layout_width="wrap_content"
 android:id="@+id/imageView3"
 android:src="@drawable/bb03" 
android:layout_marginLeft="497dp" 
android:layout_marginTop="153dp"
 android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true"/>

like that 15 Imageview which contains 15 bubbles in above layout….

Now I have one screen where level is selected and depending I put the level1 in that gamplayScreen.xml i.e. i inflate it in the gamePlayScreen which has Headup display at the left and this level screen which will keep on changing….

Before inflating my level on the gamePlayScreen …. I want to pickup random 8 bubbles which can be only clickable by user. At every level there will be 15 bubbles visible but i want to pick random 8 every level depending on the respective bubbles at that level…
here is the gamePlayActivity

 public class GamePlayActivity extends Activity {

    static int ObjectsFound;


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


            // ViewGroup where n number of view is going to added
            ViewGroup layout= (ViewGroup) findViewById(R.id.GamePlayScreen);

            // inflating the layout depending on the level 
            View level = View.inflate(this, LevelSelectionActivity.levelscreen, null);
    // adding level bg for the respective selected level
            layout.addView(level);
}   

 public void objectClick(View objectClicked)
     {
         Toast msg;
         int Object = objectClicked.getId();
         ImageView img= (ImageView)findViewById(objectClicked.getId());
        switch (Object) {
        case R.id.imageView1:   
             img.setVisibility(View.INVISIBLE);
             msg = Toast.makeText(GamePlayActivity.this, "Bubble Found", Toast.LENGTH_SHORT);
             msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
             msg.show();

            break;

        }
}

Now how to perform that random 8 objects out of the 15 object that I have in ImageView i want to set them as nonclickable ?
I hope i have explained the thing where i m too confused …

  • 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-30T06:59:32+00:00Added an answer on May 30, 2026 at 6:59 am

    Pseudocode, haven’t tested this but should work for you:

    private int[] ids = {
       R.id.imageView1,
       R.id.imageView2,
       R.id.imageView3,
       R.id.imageView4,
       ...
    }
    
    
    public void randomize() {
       Random generator = new Random();
       for(int i = 0; i<8 ; i++) {
           while(true) {
               View v = findViewById(generator.nextInt(ids.length));
               if(!v.isClickable()) {
                    v.setClickable(false);
                    break;
               }
           }
       }
    }
    

    Basically we pick 8 random views and set them as non-clickable. If we nail a view that was already made not clickable (because we’ve made it so at a previous step) we repick. Good luck!

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

Sidebar

Related Questions

I'm making a small game for a school project, and basically there are 20
I've been making small scale projects for a while now. I haven't started a
I am making a small game in flash, I would like to track scores
i am making a small project which will be incorporated into larger project. basically
I am making a small 2d GAME PACK as my University project. I am
I'm making a small game in Java and would like to add a Quake
I am making a small game. In BattleRecord.h: #ifndef _CHARACTER_H_ #define _CHARACTER_H_ #include Character.h
I am making a small game, and I need some more help with it.
I am making this small and simple game with Java, and when I start
I'm making a small platform game with the canvas element and I'm having trouble

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.