如何显示一个片段里面一个TextView文本 [英] How to display text in a TextView inside a Fragment
本文介绍了如何显示一个片段里面一个TextView文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎是一个简单的问题给我,但我不能弄明白。我有这个code我里面的片段:
Seems like a simple question to me, but I can't figure it out. I have this code inside my Fragment:
myTextView.setText("Test");
不过,这code刹车我的应用程序,而且我不确定为什么。也许这是一个意见冲突,但我还是不明白为什么它不会工作。有什么建议?
However, this code brakes my app and I am unsure why. Perhaps this is a conflict with Views, but I still don't understand why it wont work. Any suggestions?
推荐答案
你是怎么设置的内容?
How did you set the content?
编辑我的答案:)试试这个
Edited my answer :) try this
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.xmlName,
container, false);
TextView tv= (TextView) **view**.findViewById(R.id.textViewName);
tv.setText("yourText");
return view;
}
下面是片段教程:片段教程
这篇关于如何显示一个片段里面一个TextView文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文