开发者

Problem with Image Button visibility! Android

开发者 https://www.devze.com 2023-03-25 23:40 出处:网络
I have an Image button. I made it invisible. But the onClick event is not getting triggered which makes the button visible. The button should initially be visible for 5seconds, become invisible and th

I have an Image button. I made it invisible. But the onClick event is not getting triggered which makes the button visible. The button should initially be visible for 5seconds, become invisible and then visible again i开发者_运维问答f I click there.

private ImageButton nextbutton;
    @Override
    protected void onCreate( Bundle savedInstanceState )
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.first );
        nextbutton = ((ImageButton)findViewById( R.id.NextButton ));
        nextbutton.setVisibility(View.INVISIBLE);
        nextbutton.setOnClickListener( new OnClickListener()
        {
            @Override
            public void onClick( View v )
            {
                nextbutton.setVisibility(View.VISIBLE);
                startActivity( new Intent( FirstActivity.this, SecondActivity.class ) );
            }
        });
    }


You are trying to click an invisible button? Try using a visible button with a blank drawable, ie no background or src attributes.

when you click it, dynamically change the source attributes by inserting your desired drawable.

this will definitely make it clickable.


When you have made the ImageButton Invisible then how will you click an invisible ImageButton.

0

精彩评论

暂无评论...
验证码 换一张
取 消