与图像按钮知名度的问题!安卓 [英] Problem with Image Button visibility! Android

查看:124
本文介绍了与图像按钮知名度的问题!安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形象的按钮。我已不可见。但onClick事件是没有得到触发,这使得该按钮可见。该按钮应该首先是可见的5秒,成为无形然后再次可见,如果我点击那里。

 私人的ImageButton Next按钮;
    @覆盖
    保护无效的onCreate(包savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.first);
        Next按钮=((的ImageButton)findViewById(R.id.NextButton));
        nextbutton.setVisibility(View.INVISIBLE);
        nextbutton.setOnClickListener(新OnClickListener()
        {
            @覆盖
            公共无效的onClick(视图v)
            {
                nextbutton.setVisibility(View.VISIBLE);
                startActivity(新意图(FirstActivity.this,SecondActivity.class));
            }
        });
    }
 

解决方案

您正试图点击一个看不见的按钮?尝试使用一个可见的按钮带有空白绘制,即没有背景或SRC属性。

当你点击它,动态改变插入所需的绘制属性的源。

这必将使其点击。

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 if 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.

这篇关于与图像按钮知名度的问题!安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆