Denoteone
Denoteone

Reputation: 4055

Android - How do you make a button invisible but still active?

I am trying to create a "hot spot" on my tablet that acts like a button but users can not see the button. When I try the following I have a button but when visibility is set to "4" the user cannot interact or see it:

  Button b=(Button)findViewById(R.id.b);
      b.setOnClickListener(listener);
      b.setVisibility(4);

    public OnClickListener listener=new OnClickListener(){

        public void onClick(View arg0) {
        Intent myIntent = new Intent(MeetingManager.this,GetRoom.class);
           startActivityForResult(myIntent, 0);
        }
    };

Any ideas how I can achieve the above request?

Upvotes: 3

Views: 4396

Answers (2)

A.Jouni
A.Jouni

Reputation: 387

Also you can add a normal button and change its background to a transparent png picture it works fo me !

Upvotes: 0

MrZander
MrZander

Reputation: 3120

If it is going to be invisible, why does it have to be a button?

You can add an OnClickListener to any view.

Why not use an ImageView with a transparent background and just add the OnClickListener to that?

Upvotes: 10

Related Questions