Unable to inflate a layout on button click

断了今生、忘了曾经 提交于 2019-12-13 08:22:36

问题


Hi I am trying to show a layout when a button is pressed but the layout is never shown. No exception is thrown for some reason. The button is located inside an activity. The button is called and declared and it works. The calling of the layout is just additional action to the button.

Here is my code to inflate the layout:

 LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
 View error = layoutInflater.inflate(R.layout.error_search_no_results,null);

回答1:


Use this :

rv.addView(error);

Where rv is your parent layout.



来源:https://stackoverflow.com/questions/27901244/unable-to-inflate-a-layout-on-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!