I have the activity that have two Layout the first Layout VISIBLE and second is Gone. Now I have ImgView when pressed it open the Layout Gone , change Image to close Image and when press again close this Layout . I am wondering how I can use the same Img View for opening and closing Layout?
Asked
Active
Viewed 1,134 times
1 Answers
2
try this
create boolean openLayout=true; at the top of activity
imgView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(openLayout){
layout1.setVisibility(View.VISIBLE);
layout2.setVisibility(View.Gone);
openLayout = false;}
else{
layout1.setVisibility(View.Gone);
layout2.setVisibility(View.VISIBLE);
openLayout = true;
}
});
Aditya
- 3,115
- 1
- 25
- 34
Kapil Parmar
- 816
- 7
- 18