Android 在片段中更新textview

Android 在片段中更新textview,android,eclipse,android-fragments,Android,Eclipse,Android Fragments,这可能是一个非常简单的问题,但我似乎无法让它工作 我正在尝试更新“OnCreateView”中片段中的textview 我的代码如下所示 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_display_product, container, fal

这可能是一个非常简单的问题,但我似乎无法让它工作

我正在尝试更新“OnCreateView”中片段中的textview 我的代码如下所示

public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
     View v = inflater.inflate(R.layout.fragment_display_product, container, false);
    txtAge = (TextView)v.findViewById(R.id.txtAge);
    txtCountry = (TextView)v.findViewById(R.id.txtCountry);
    txtName = (TextView)v.findViewById(R.id.txtName); 
    txtAge.setText("Hallo world");
    return inflater.inflate(R.layout.fragment_display_product, container,false);
}
textview txtAge中的文本从未设置,我似乎找不到原因。 我是android新手,如果这是个愚蠢的问题,我很抱歉

/伯杰

像这样做-

public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) 
{
    View v = inflater.inflate(R.layout.fragment_display_product, null);
    txtAge = (TextView)v.findViewById(R.id.txtAge);
    txtCountry = (TextView)v.findViewById(R.id.txtCountry);
    txtName = (TextView)v.findViewById(R.id.txtName); 
    txtAge.setText("Hallo world");
    return v;
}
返回您已经夸大的相同视图。

Perfect:)我不敢相信我错过了。谢谢,我会接受您的回答