由于错误信息是:java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.layouttest:id/container) for fragment PlaceholderFragment{我感觉错误不在现在楼主贴出的代码上,可能在
setContentView(llpage);
之后中代码中。
能否再将之后代码贴出一些?
解决方案 »
- HTTP POST协议 输出流不阻塞是什么情况
- android真机调试的几个问题
- 代码实现删除系统应用
- android下面关于视频的压缩
- 怎么每次编辑虚拟器的时候Device都是空的?
- Android 数据库 在使用 update更新的时候,总是无法更新,还没有异常抛出!
- android中webview加载网页或网页切换时出现白屏现象
- Failed to install *.apk on device 'emulator-5554': timeout
- cordova build 编译出错
- android平台如何让我的应用程序能够访问别的应用程序的数据目录?
- Android通过联系人id查询联系人的分组
- 监听应用开启
这句说的很清楚了!
public class MyFragment extends Fragment{
private LinearLayout llpage;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
llpage = new LinearLayout(getActivity());
llpage.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
llpage.setOrientation(LinearLayout.VERTICAL);
// 创建TextView对象
TextView mTextView = new TextView(getActivity());
// 设置文字
mTextView.setText("hello world");
LinearLayout.LayoutParams mLayoutParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
// 在父类布局中添加它,及布局样式
llpage.addView(mTextView, mLayoutParams);
return llpage;
}
}