android 嵌套 xml,为什么嵌套 Fragments 不能使用 XML?_android-fragments_开发99编程知识库...

google我看到很多聲明嵌套 Fragments的聲明不能使用 XML 。 現在我是Android的新手,但我的應用程序使用嵌套的Fragments 。 我還沒有讓監聽器和介面工作,( 也許這就是人們說你不能使用XML的原因),但是GUI工作。

我的問題:我所閱讀的關於不使用XML的嵌套 Fragments的註釋是什麼意思?

這裡是一個鏈接鏈接,指向一個聲明XML不能使用嵌套的Fragments:

下面的代碼創建 3 radiogroups ( 在 fragment 中) 水平排列在頂部( 在另一個 fragment 中),下面是一個 listview ( 在另一個 fragment 中) 。 Fragments 允許對不同顯示類型的查找進行良好的控制。

這是我的代碼:public class SetupNew extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.ngs);

}}

ngs.xml

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

android:layout_height="250dp"

android:layout_width="fill_parent"

android:layout_marginLeft="5dp"

android:layout_marginRight="5dp"

android:name="com.EXAMPLE.frag_class_options_all"/>

android:layout_height="fill_parent"

android:layout_marginLeft="5dp"

android:layout_marginTop="10dp"

android:layout_width="fill_parent"

android:name="com.EXAMPLE.frag_class_opponents"/>

frag_class_options_all.javapublic class frag_class_options_all extends Fragment {

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

View view = inflater.inflate(R.layout.options_all, container, false);

return view;

}}

frag_class_opponents.javapublic class frag_class_opponents extends ListFragment implements LoaderManager.LoaderCallbacks {

//working contact listview

}

options_all.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal">

android:layout_height="fill_parent"

android:layout_width="80dp"

android:layout_marginRight="15dp"

android:name="com.EXAMPLE.frag_class_options"/>

android:layout_height="fill_parent"

android:layout_width="75dp"

android:layout_marginRight="15dp"

android:name="com.EXAMPLE.frag_class_limit_options"/>

android:layout_height="fill_parent"

android:layout_width="fill_parent"

android:name="com.EXAMPLE.frag_class_allow"/>

英鎊 frag_class_options,frag_class_limit_options英鎊和英鎊都遵循如下所示:public class frag_class_options extends Fragment{

RadioGroup radioGroup;

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

View view = inflater.inflate(R.layout.options_m, container, false);

radioGroup = (RadioGroup) view.findViewById(R.id.rg_limit);

return view;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值