安卓:如何访问片段布局对象?

4

我有一个使用fragment的应用程序。我正在使用与Android 2.2向后兼容的包。我可以轻松地填充xml,但是当我尝试访问充气布局上的对象时,问题就开始了。LogCat会抛出“错误膨胀类片段”。我做错了什么?这是我的代码:

View view001 = inflater.inflate(R.layout.bottom_right_view,container,false);
TextView text001= (TextView)getActivity().findViewById(R.id.textView1);
text001.setText("Sample text");
1个回答

5
View view001 = inflater.inflate(R.layout.bottom_right_view,container,false);
TextView text001= (TextView)view001.findViewById(R.id.textView1);  
text001.setText("Sample text");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接