i have one layout like this
when click in layer1,layer 2 get invisible but when i click on layer2 it do not go to invisible. i use the following code,but it's not working,when i click layer2 it also go to invisible, any idea to get visible of layer2 when i click layer2.
RelativeLayout layout1=(RelativeLayout)findViewById(R.id.hidebg);
final RelativeLayout layout=(RelativeLayout)findViewById(R.id.hidelayer);
layout1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(layout.getVisibility()==0)
{
layout.setVisibility(4);
}
else
{
layout.setVisibility(0);
}
}
});
Add event listener on the second layout
layout.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(i==0)
{
layout.setVisibility(4);
i=1;
}
else
{
layout.setVisibility(0);
i=0;
}
}
});
Then check.
set layer2 as visible by default and use this code :
layer1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(layer2.getvisibility==View.VISIBLE)
{
layer2.setVisibility(View.GONE);
}
else
{
layer2.setVisibility(View.VISIBLE);
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With