Android listfragment 简单例子
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12074002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
listfragment simple example
提问by Barak
Hello i want to get simple list fragment example i have searched out but could not get it so please can any body help me
您好,我想获得简单的列表片段示例,我已经搜索过但无法获得,所以请任何机构帮助我
import android.support.v4.app.Fragment;
i have searched out but mostly in import android.app.*;
我已经搜索过了,但主要是在 import android.app.*;
so any body help me to find out example so it is not working on my android 2.2
所以任何机构都可以帮助我找出示例,因此它不适用于我的 android 2.2
if (savedInstanceState == null) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ListFragment listFragment = new ListFragment();
ft.add(R.id.displayList, listFragment, "List_Fragment");
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
i m getting error over getFragmentmanger
我在 getFragmentmanger 上出错
this example must be in below android 3.0
此示例必须在 android 3.0 以下
回答by Andrius Baruckis
Another very simple list fragment example:
另一个非常简单的列表片段示例:
http://wptrafficanalyzer.in/blog/a-listfragment-application-in-android/
http://wptrafficanalyzer.in/blog/a-listfragment-application-in-android/
回答by Barak
When using the support library, you need to use getSupportFragmentManager
(the method name in the support library) instead of getFragmentManager
(which is the method name in post 3.0).
使用支持库时,需要使用getSupportFragmentManager
(支持库中的方法名)而不是getFragmentManager
(3.0后的方法名)。
回答by Aerilys
Here you have a simple example of fragment, easily adaptable for Listfragment
这里有一个简单的片段示例,可轻松适应 Listfragment