如何将 simpleExpandableListAdapter 或类似的东西应用于 ListFragment 中的 ListView

发布于 2024-11-30 04:14:01 字数 847 浏览 8 评论 0原文

我正在使用 ListFragment 并想要制作一个困难的列表,其中有子列表,并且不知道如何做到这一点(( 一些代码:

public class CarsOfBrandFragment extends ListFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        String[] s = {"colorName"};
        int[] k = {R.id.groupname};
        String[] s1 = new String[]{"shadeName", "rgb"};
        int[] k1 = new int[]{R.id.childname, R.id.rgb};
        SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(), createGroupList(),
            R.layout.grouprow, s, k, createChildList(), R.layout.childrow, s1, k1);
        setListAdapter(expListAdapter);
    }

android.support.v4.app.ListFragment 中的 setListAdapter(android.widget.ListAdapter) 无法应用于 (android.widget.SimpleExpandableListAdapter)

I am working with ListFragment and want to make a difficult list, which has sublists and don't know how I can do it((
Some code:

public class CarsOfBrandFragment extends ListFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        String[] s = {"colorName"};
        int[] k = {R.id.groupname};
        String[] s1 = new String[]{"shadeName", "rgb"};
        int[] k1 = new int[]{R.id.childname, R.id.rgb};
        SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(getActivity(), createGroupList(),
            R.layout.grouprow, s, k, createChildList(), R.layout.childrow, s1, k1);
        setListAdapter(expListAdapter);
    }

setListAdapter(android.widget.ListAdapter) in android.support.v4.app.ListFragment cannot be applied to (android.widget.SimpleExpandableListAdapter)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿港小镇 2024-12-07 04:14:01

你不能把它设置在ListView本身上吗?

ListView lv = (ListView) findViewById(R.id.your_list);
lv.setAdapter(expListAdapter);

Can't you just set it on the ListView itself?

ListView lv = (ListView) findViewById(R.id.your_list);
lv.setAdapter(expListAdapter);
ˇ宁静的妩媚 2024-12-07 04:14:01

好吧,我通过显式指示 ExapndableListView 来决定这一点 - 是的,我在 Expandable 上更改了通常的 ListView,并使用 SimpleCursorTreeAdapter 而不是 SimpleExpandableListAdapter

Ok I decided this by explicit indicating of ExapndableListView - yes I changed usual ListView on Expandable, and using SimpleCursorTreeAdapter instead of SimpleExpandableListAdapter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文