2015-09-15 27 views
-3
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 

    et=(EditText)rootView.findViewById(R.id.et1); 

    String str=et.getText().toString(); 



    Fragment frag=new Fragment(); 
    Bundle bundle1=new Bundle(); 
    bundle1.putString("name", str); 
    frag.setArguments(bundle1); 
    getFragmentManager().beginTransaction().add(R.id.container_body, frag).commit(); 

    return inflater.inflate(R.layout.fragment_currentmovie, container, false); 
} 

}我有一個錯誤在我rootView

它顯示rootView不能得到解決,我需要編輯文本等添加到字符串str因此使用捆綁我可以將它傳遞到下一個片段

+0

做得一樣'查看rootView = inflater.inflate(R.layout.fragment_currentmovie,容器,FALSE);',也返回''從onCreateView' –

+0

rootView rootView'應該是您正在膨脹的人;返回最後一行 –

+0

我需要替換返回inflater.inflate(R.layout.fragment_currentmovie,容器,false);與迴歸rootview – user3409897

回答

0

嘗試此附加吹氣,然後返回。

@Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
        Bundle savedInstanceState) { 

View rootView = inflater.inflate(R.layout.fragment_currentmovie, container, false); 
et=(EditText)rootView.findViewById(R.id.et1); 

String str=et.getText().toString(); 



Fragment frag=new Fragment(); 
Bundle bundle1=new Bundle(); 
bundle1.putString("name", str); 
frag.setArguments(bundle1); 
getFragmentManager().beginTransaction().add(R.id.container_body, frag).commit(); 

return rootView ; 
} 
} 
0

您需要首先它充氣:

View rootView = inflater.inflate(R.layout.fragment_currentmovie, container, false); 
... 
return rootview; 
+0

我需要替換 – user3409897

+0

返回inflater.inflate(R.layout.fragment_currentmovie,容器,假);與返回rootview – user3409897

相關問題