我正在尝试在 Fragment 上实现 SwipeRefreshLayout。
我已经解决了它在 Activity 上实现它,但是当我在 Fragment 上实现它时:java.lang.NoClassDefFoundError: com...
有人有想法吗?谢谢!
没有答案/解决方案的类似帖子:Swipe Refresh Layout - Class not found
我的代码:
public class Principal extends Fragment implements OnRefreshListener {
SwipeRefreshLayout swipeLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.principal, container, false);
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
return view;
}
}
还有我的布局:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.enhancedListView.EnhancedListView
android:id="@+id/listaNoticias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="5dp" >
</com.enhancedListView.EnhancedListView>
</android.support.v4.widget.SwipeRefreshLayout>
完整的堆栈跟踪
08-13 11:36:19.292: E/AndroidRuntime(31572): FATAL EXCEPTION: main
08-13 11:36:19.292: E/AndroidRuntime(31572): Process: com.xxx.xx, PID: 31572
08-13 11:36:19.292: E/AndroidRuntime(31572): java.lang.NoClassDefFoundError: com.xxx.fragments.Principal
08-13 11:36:19.292: E/AndroidRuntime(31572): at com.xxx.hem.activities.MainActivity.CargarPrincipal(MainActivity.java:676)
08-13 11:36:19.292: E/AndroidRuntime(31572): at com.xxx.hem.activities.MainActivity.onCreate(MainActivity.java:297)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.Activity.performCreate(Activity.java:5231)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.ActivityThread.access$800(ActivityThread.java:135)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.os.Handler.dispatchMessage(Handler.java:102)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.os.Looper.loop(Looper.java:136)
08-13 11:36:19.292: E/AndroidRuntime(31572): at android.app.ActivityThread.main(ActivityThread.java:5001)
08-13 11:36:19.292: E/AndroidRuntime(31572): at java.lang.reflect.Method.invoke(Native Method)
08-13 11:36:19.292: E/AndroidRuntime(31572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-13 11:36:19.292: E/AndroidRuntime(31572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
最佳答案
解决了:)
我的 XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.enhancedListView.EnhancedListView
android:id="@+id/listaNoticias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="5dp" >
</com.enhancedListView.EnhancedListView>
</android.support.v4.widget.SwipeRefreshLayout>
我的 fragment
public class Principal extends Fragment implements OnRefreshListener {
SwipeRefreshLayout swipeLayout;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.principal, container, false);
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorSchemeColors(android.R.color.holo_green_dark,
android.R.color.holo_red_dark,
android.R.color.holo_blue_dark,
android.R.color.holo_orange_dark); (...)
@Override
public void onRefresh() {
new myTask().execute();
}
关于android - 在 Android Fragment 中滑动刷新布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25245088/
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我有一个Sinatra应用程序,它有一个长时间运行的进程(网络抓取工具)。我希望应用程序在爬虫运行时而不是在结束时刷新爬虫进度的结果。我已经考虑过fork请求并使用ajax做一些有趣的事情,但这是一个非常基本的单页应用程序,实际上只需要在它发生时将日志输出到浏览器。有什么建议吗? 最佳答案 更新(2012-03-21)从Sinatra1.3.0开始,您可以使用新的流式API:get'/'dostreamdo|out|out旧答案不幸的是,您没有可以简单地刷新到的流(这不适用于Rack中间件)。从路由block返回的结果可以简单地响应
我想为网站的管理和公共(public)部分设置一对样式指南。每个都需要自己的布局,其中包含静态html和调用erbpartials的混合(因此静态页面不会削减它)。我不需要Controller来为这些页面提供服务,而且我不希望有效的仅开发内容使其余代码困惑。这让我想知道是否有一种方法可以直接呈现布局。免责声明:我明白这不是我应该经常/永远做的事情,而且我知道有很多争论可以解释为什么这是一个坏主意。我对这是否可能感兴趣。有没有办法让我直接从routes.rb渲染布局而不通过Controller? 最佳答案 出于某种奇怪的原因,我想暂时
这个问题在这里已经有了答案:differentlayoutforsign_inactionindevise(8个答案)关闭7年前。如何更改设计Controller中的布局?
我有request.env['http_host']在本地主机上工作,但在heroku的布局页面中引用时会导致错误。此请求在View中工作并显示正确的基本url,但是当我将代码移动到布局时它会导致错误。注意-我正在使用它来为html电子邮件中的图像构建绝对url。收到错误:ActionView::Template::Error(undefinedmethod`env'fornil:NilClass): 最佳答案 如果你想要没有端口的主机,只需使用:request.host编辑:糟糕,我刚刚注意到您正在使用View中的代码。我不知道它
我对RubyGUI设计做了很多研究,这似乎是Ruby倾向于落后的领域。我探索了MonkeyBars、wxRuby、fxRuby、Shoes等选项,只是想从Ruby社区获得一些意见。虽然它们绝对可用,但每一个的开发似乎都在下降。我在任何(减去fxRuby书)上都找不到大量有用的文档或用户基础。我只是想制作一个简单的GUI,所以我真的不想花费数百小时来学习更复杂的工具的复杂性或尝试使用甚至不再开发的东西(鞋子是应用程序的类型我正在寻找,但它有很多问题并且没有得到积极开发。)在所有选项中,你们会推荐哪个选项是最快的,并且仍然具有某种开发基础?谢谢! 最佳答案
运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid
1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La
我正在覆盖设计注册Controller的创建操作。我有两种注册表格,个人或公司,公司有一个名为company_form的字段设置为true以区分这两种表格。在表单验证后,我希望呈现正确的表单(以前无论我使用什么表单,它都会返回默认表单)。我遇到了一个问题,即只渲染了部分(很明显,因为我只渲染了部分),但我还需要渲染布局/应用程序文件。classRegistrationsControllerifresource.company_formrenderpartial:'shared/company_signup_form'elserenderpartial:'/shared/individu