问题
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