[英]Fragment layout in android
我在我的應用程序中使用片段布局。 但是我想使用我在Oncreate Bundle中編寫的代碼,因此如何在OncreateView中編寫代碼。 這是片段布局的代碼。
public class Text extends Fragment {
public Text(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.text_to_speech, container, false);
return rootView;
}
因此,我必須使用oncreate包,或者可以在OncreateView中編寫相同的代碼。
救命。 謝謝。
如果您通過捆綁包傳遞了一些數據,則可以得到如下所示的捆綁包。
Bundle bundle = getArguments();
我們為此使用此方法。
public void onActivityCreated(Bundle savedInstanceState1) {
super.onActivityCreated(savedInstanceState1);
}
Fragment類沒有oncreate()方法。您可以在oncreateView()中編寫代碼。檢查Fragment的生命周期。 請點擊以下鏈接
http://developer.android.com/guide/components/fragments.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.