开发者

Best way to create dynamic footer depending on the view, android

开发者 https://www.devze.com 2023-03-16 00:53 出处:网络
I am creating an application. in every screen of the application I have to add footer. If the orientation change to landscape then there should be no footer otherwise there should be footer. in that f

I am creating an application. in every screen of the application I have to add footer. If the orientation change to landscape then there should be no footer otherwise there should be footer. in that footer there should be three buttons. if i am in first page then first page will be in selected if i am in s开发者_如何学编程econd page then second button should be selected. I want this type of functionality. To achieve this i can create a footer layout and add in the xml of every screen but i want to select the buttons depending on the page and also hide or show the footer depending on the orientation. How can I achieve this?

Thanks Sunil


  1. To deal with showing/hiding the footer I do this at the end of my onCreate method:

    if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){ footer.setVisibility(View.GONE); }

  2. To deal with selecting the button just add a line of code that selects the appropriate button based on the activity.

0

精彩评论

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