草庐IT

android - 充气类 android.support.v4.widget.SwipeRefreshLayout

coder 2023-11-28 原文

我正在尝试在 fragment 中实现 SwipeRefreshLayout。它看起来创建正确,但我仍然收到错误:

Caused by: android.view.InflateException: Binary XML file line #2: 
Binary XML file line #2: Error inflating class 
android.support.v4.widget.SwipeRefreshLayout
Caused by: android.view.InflateException: Binary XML file line #2: 
Error inflating class android.support.v4.widget.SwipeRefreshLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class 
"android.support.v4.widget.SwipeRefreshLayout" on path: 
DexPathList[[zip file "/data/app/com.weather.rainy- 
2/base.apk"],nativeLibraryDirectories=[/data/app/com.weather.rainy- 
2/lib/x86, /system/lib, /vendor/lib]]

我真的不知道是什么原因造成的。

我实现 SwipeRefreshLayout 的 fragment 布局:

    <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/swipeToRefresh4Maps"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/topRL4Maps"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bg_gradient_purple"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingTop="64dp"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingBottom="64dp"
        tools:context="com.weather.rainy.ui.MapsActivity">

        <TextView
            android:id="@+id/yourLocationLabelTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:text="@+string/your_location"
            android:textColor="@android:color/white"
            android:textSize="24sp" />

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/addressValueTextView"
            android:layout_alignBottom="@+id/addressValueTextView"
            android:layout_below="@+id/yourLocationLabelTextView"
            android:layout_centerHorizontal="true"
            android:layout_margin="15dp"
            tools:context="com.weather.rainy.ui.MapsActivity" />

        <TextView
            android:id="@+id/addressValueTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignStart="@+id/map"
            android:layout_alignEnd="@+id/map"
            android:layout_alignParentStart="false"
            android:layout_alignParentBottom="true"
            android:text="@+string/..."
            android:textColor="#aaffffff"
            android:textSize="18sp" />
    </RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>

还有,我调用 SwipeRefreshLayout 的 fragment 类:

  //Code for Swipe Refresh
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh4Maps);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.Red, R.color.Orange, R.color.Blue, R.color.Green);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.v(TAG, "************** MAPS - SWIPE REFRESH EVENT TRIGGERED!!!!!");
            findLocation();
        }
    });

我真的不知道有什么问题。非常感谢任何帮助。

最佳答案

因为您使用的是 AndroidX,所以您的 XML 引用了错误版本的 SwipeRefreshLayout

将您的 XML 从 android.support.v4.widget.SwipeRefreshLayout 更改为 androidx.swiperefreshlayout.widget.SwipeRefreshLayout

关于android - 充气类 android.support.v4.widget.SwipeRefreshLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54932305/

有关android - 充气类 android.support.v4.widget.SwipeRefreshLayout的更多相关文章

  1. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  2. ruby-on-rails - 当需要 active_support 时,cattr_accessor 不工作(在 rails 之外)? - 2

    我不熟悉active_support,所以请多多包涵!Fox'slibrary允许通过谷歌的API进行搜索,但它需要积极的支持。我似乎无法让它工作!有什么想法吗?require'rubygems'require'active_support'require'google_search'pGoogleSearch.web:q=>"HelloWorld!"给我:NoMethodError:undefinedmethod‘cattr_accessor’forGoogleSearch:Class知道我做错了什么吗? 最佳答案 通过更多的谷歌

  3. ruby-on-rails - 活跃商家 : How to authorise cards when using gateways that do not support the void operation? - 2

    我正在使用ActiveMerchant开发RubyonRails应用程序的计费组件。我们选择的支付网关是PaymentExpress.我看到的代码示例如下所示,使用authorize()和void()来测试卡的有效性:deftest_card!auth_response=gateway.authorize(100,card)gateway.void(auth_response.authorization)ifauth_response.success?raiseAuthorizationFailed.new(auth_response)unlessauth_response.succe

  4. ruby-on-rails - Ruby on Rails 教程 - 5.26 - Sublime Text "Unable to Save"新文件 "spec/support/utilities.rb" - 2

    我正在使用SublimeText2,同时遵循MichaelHartl的RubyonRails教程。可以在http://ruby.railstutorial.org/book/ruby-on-rails-tutorial找到我所指的教程的具体部分。(ctrl+F“list5.26”)。我能够创建规范/支持文件。但是,在尝试创建spec/support/utilities.rb文件时,我收到消息“无法保存~/rails_projects/sample_app/spec/support/utilities.rb”。有人知道为什么会这样吗?SublimeText论坛上有人似乎遇到了完全相同的问

  5. ruby-on-rails - 试图在 gem 中要求 active_support - 2

    我有一个ruby​​gem,我想在包含在railsactive_support模块中的gem中使用Hash.from_xml方法。我的gemspec中有以下代码:gem.add_dependency'active_support','~>3.0.0'但是,当我在本地构建和安装gem、运行irb、需要gem时,我没有看到包含主动支持的方法?关于我做错了什么或如何调试有什么建议吗?谢谢! 最佳答案 您需要从ActiveSupport要求您需要的方法;默认情况下不添加它们。正如Yevgeniy在评论中提到的那样,如果您需要所有内容,则执行

  6. nginx配置https后报错nginx: [emerg] https protocol requires SSL support in XXX.conf详细解决方法 - 2

    一、前言最近,在测试环境的nginx里增加了一个https配置:location/api-meeting-qq/{proxy_passhttps://api.meeting.qq.com/;}然后,执行命令://这个是nginx启动文件的路径,根据实际情况自行更改sudo/home/useradmin/nginx/sbin/nginx-sreload结果,nginx就报错了:nginx:[emerg]httpsprotocolrequiresSSLsupportin/home/useradmin/nginx/conf.d/trainNginx.conf:9二、解决方法百度发现,是之前安装ngi

  7. Android Studio开发之使用内容组件Content获取通讯信息讲解及实战(附源码 包括添加手机联系人和发短信) - 2

    运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid

  8. Android 10.0 设置默认launcher后安装另外launcher后默认Launcher失效的功能修复 - 2

    1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La

  9. ruby - 如何解析 "Your bundle only supports platforms ["x86-mingw3 2"] but your local platforms are ["ruby​​", "x86_64-linux"]" - 2

    我正在Windows机器上构建一个Rails站点,但是当我检查我的Gemfile.lock时,我在我的Travis构建中遇到以下错误:Yourbundleonlysupportsplatforms["x86-mingw32"]butyourlocalplatformsare["ruby","x86_64-linux"],andthere'snocompatiblematchbetweenthosetwo列表这是完整的日志:https://travis-ci.org/bikebike/BikeBike/builds/222395810#L654我查看了我的Gemfile.lock并指出:

  10. AiBote 2022 新研发的自动化框架,支持 Android 和 Windows 系统。速度非常快 - 2

    Ai-Bot基于流行的Node.js和JavaScript语言的一款新自动化框架,支持Windows和Android自动化。1、Windowsxpath元素定位算法支持支持Windows应用、.NET、WPF、Qt、Java和Electron客户端程序和ie、edgechrome浏览器2、Android支持原生APP和H5界面,元素定位速度是appium十倍,无线远程自动化操作多台安卓设备3、基于opencv图色算法,支持找图和多点找色,1080*2340全分辨率找图50MS以内4、内置免费OCR人工智能技术,无限制获取图片文字和找字功能。5、框架协议开源,除官方node.jsSDK外,用户可

随机推荐