2014-04-10 3 views
0

이것은 매우 간단한 문제 일 수는 있지만 제대로 작동하지 않는 것 같습니다. 나는 "OnCreateView"에 조각에서 텍스트 뷰를 업데이트하기 위해 노력하고있어조각의 텍스트 뷰 업데이트

는 내 코드 txtAge가 설정되지는 결코 텍스트 뷰에서이

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

텍스트처럼 보인다 나는 이유를 찾을 수 없습니다 . 안드로이드에 처음 왔어. 어리석은 질문이라면 미안해.

/비르는

답변

1

는 this-

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

돌아처럼 이미 팽창 한 동일한보기를 해.

+0

완벽한 :) 나는 내가 그것을 놓친 것을 믿을 수 없다. 고맙다 나는 당신의 대답을 받아 들일 것이다. – Birger