我可以创建片段ListActivity与兼容包V4? [英] Can I create Fragment ListActivity with compatibility package v4?

查看:113
本文介绍了我可以创建片段ListActivity与兼容包V4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图完成教程这是专为有碎片的工作的Andr​​oid 3.0 +

I've been trying to complete tutorial "Working with fragments" which was designed for android 3.0+

要acomplish我使用兼容包V4(因为我的API是7)。不过我卡上的列表。我找不到直接的答案。

To acomplish that I'm using compatibility package v4 (since my API is 7). However I'm stuck on the lists. I couldn't find straight answer.

我收到一个ClassNotFoundException。我继承片段类从FragmentActivity但对于我ListActivity?有没有这样的事情FragmentListActivity,我认为它不断崩溃,在这一点。

I'm getting a ClassNotFoundException. I inherited fragment class from FragmentActivity but what about my ListActivity? There is no such thing as FragmentListActivity and I think it keeps crashing at this.

我可以创建片段ListActivity与兼容包V4?或者,这是不可能的呢?

Can I create Fragment ListActivity with compatibility package v4? Or it's not possible at all?

推荐答案

不,不存在。愚蠢的支持库。

Nope, doesn't exist. Stupid support library.

该解决方案易于创建,但繁琐的维护。刚才复制的<一个href="https://raw.github.com/android/platform_frameworks_base/d6c1919779acb042392615637b9007e0c4b89023/core/java/android/app/ListActivity.java">native ListActivity 类到您的项目,将其重命名 FragmentListActivity ,并让它延长 FragmentActivity 而不是活动。没有其他的调整是必需的,该副本是很容易。如果你不确定你能<一个href="http://bazaar.launchpad.net/~pjv/collectionista/ics-main/view/head:/collectionista-library/src/net/lp/collectionista/util/FragmentListActivity.java">peak我的code,但它总是最好得到最新的。

The solution is easy to create but tedious to maintain. Just copy the native ListActivity class into your project, rename it "FragmentListActivity", and let it extend FragmentActivity instead of Activity. No other tweaks are required and the copy is easy. If you are uncertain you can peak at my code, but it's always best to derive the latest.

也是一样的 GridActivity 我会说。

这篇关于我可以创建片段ListActivity与兼容包V4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆