无法在充气点击按钮布局 [英] Unable to inflate a layout on button click

查看:135
本文介绍了无法在充气点击按钮布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示的布局时,按钮pssed $ P $但布局从未显示。没有异常被抛出的某些原因。该按钮位于活动中。该按钮被称为,并宣布和它的作品。布局的通话仅仅是按键额外的操作。

下面是我的code膨胀的布局:

  LayoutInflater layoutInflater =(LayoutInflater)getApplicationContext()getSystemService(LAYOUT_INFLATER_SERVICE)。
 查看错误= layoutInflater.inflate(R.layout.error_search_no_results,NULL);


解决方案

使用这样的:

  rv.addView(错误);

其中RV是你的父母布局。

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);

解决方案

Use this :

rv.addView(error);

Where rv is your parent layout.

这篇关于无法在充气点击按钮布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆