Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removeAllViews and setContentView not working

I have a problem with removeAllViews and setContentView..... both are not working for me i don't know why. I have a function in a class that return a view and i want to add that view to the screen and that view will be change after every 5 second..... so after 5 second i call removeAllViews on the layout in which the view is added and then add it again.... but surprisingly the old view is still there and it add the new view at the end....

Same problem with the setContentView i try this also but it also work same as main layout it also add the view at the end not replace the whole screen.......

please help...... thanks in advance............

setContentView(logic.getView());

and

LinearLayout layout = blah blah blah;
layout.removeAllViews();
layout.addView(logic.getView(), layout parameters....);
like image 945
Hamdullah shah Avatar asked Nov 14 '22 11:11

Hamdullah shah


1 Answers

Ok. With some of the review of your comments i got why this issue is created.

May be You are not removing the first View properly. Thats why while you are going to add another view, there are two views(1st is previous one and second is newly added view) instead of the one new View.

So remove the first view properly and then add the view as you want.

Hope it will help you.

Thanks.

Enjoy. :)

like image 114
Shreyash Mahajan Avatar answered Nov 16 '22 04:11

Shreyash Mahajan