Android SDK中片段支持 [英] Android SDK Fragment Support
问题描述
好的,我刚刚开始进入Android的程序,现在,我下面的机器人TabActivity教程:的 http://developer.android.com/reference/android/app/TabActivity.html 。 逝去的工作,但它似乎无法找到一些支持类的,请参见下面的code正在生成错误。
Ok i'm just starting to get into Android programming now, and I'm following the android "TabActivity" tutorial: http://developer.android.com/reference/android/app/TabActivity.html. Everythings working but it can't seem to find some of the support classes, see the code below that is generating the errors.
mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
FragmentStackSupport.CountingFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class,null);
有关FragmentStackSupport / LoaderCursorSupport / LoaderCustomSupport / LoaderThrottleSupport,它说,对所有的人都无法解析为一个类型。我已经添加了最新的支持库名为库的根目录的文件夹,也coppied成C:/ Eclipse中/ V4 /目录下。我的导入文件是:
For FragmentStackSupport/LoaderCursorSupport/LoaderCustomSupport/LoaderThrottleSupport, it says for all of them cannot be resolved to a type. I've added the latest support library to a folder in the root directory named "libs" and also coppied it into "C:/Eclipse/v4/" directory. My import files are:
import java.util.HashMap;
import android.R;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import android.widget.TabHost;
import cowdawg.hello_tab.namespace.R.layout;
import cowdawg.hello_tab.namespace.R.id;
可能有人请我提供关于如何解决这方面的一些建议,谢谢。)
Could someone please offer me some advice on how to solve this, thanks :).
推荐答案
这可能是因为下列类不是标准的Android API(或支持库)的一部分,但只存在于支持演示示例code出于演示的目的:
It's probably because the following classes are not part of the standard Android API (or the support library), but only exist in the support demos sample code for demonstration purposes:
FragmentStackSupport.CountingFragment
LoaderCursorSupport.CursorLoaderListFragment
LoaderCustomSupport.AppListFragment
LoaderThrottleSupport.ThrottledLoaderListFragment
您需要将这些类添加到您自己的项目,以便能够使用它们。 <一href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/index.html">Here你可以找到在小节文件的源文件。
You will need to add these classes to your own project in order to be able to use them. Here you can find the source files under the subsection 'Files'.
- <一个href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentStackSupport.html"><$c$c>FragmentStackSupport$c$c>
- <一个href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.html"><$c$c>LoaderCursorSupport$c$c>
- <一个href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCustomSupport.html"><$c$c>LoaderCustomSupport$c$c>
- <一个href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderThrottleSupport.html"><$c$c>LoaderThrottleSupport$c$c>
这篇关于Android SDK中片段支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!