在ActionBar添加刷新Loading状态

【Codex教育管理系统】用知识点配置构建题库与考试分析口径 知识点配置是教育管理系统中题库、考试分析和教学内容推荐的基础口径。它维护学段、学科、知识点层级和启用状态,让题目、教材章节和成绩分析能引用同一套结构化知识体系。 阅读详情

应用场景:在界面内列表或其他部件下拉刷新时,ActionBar 出现一个转圈的刷新标示动画。 

实现方式:可使用开源类库 RefreshActionItem (https://github.com/ManuelPeinado/RefreshActionItem),RefreshActionItem 还支持一些扩展功能,功能比较丰富;

如果只需要实现一个刷新和Loading的效果,则可以使用另一种简便的实现方式:

1. 首先定义一个 Menu xml 文件, share_public.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/refresh_loading"
        android:icon="@color/transparent"
        android:showAsAction="always"
        android:title="刷新"/>

</menu>


2. 然后创建一个代表刷新进度的自定义 ProgressBar 布局文件 actionbar_indeterminate_progress.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content"
    android:layout_width="56dp"
    android:minWidth="56dp">
 
    <ProgressBar android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"
        style="?indeterminateProgressStyle" />
</FrameLayout>

注意,为了显示美观,上面的 宽度和高度 不同的版本和屏幕可能需要设置不一样的值,可以在不同的 dimens.xml 中设置。


3. 在 Activity 代码中,获取到该 MenuItem 并根据刷新情况来设置 ActionView:

	MenuItem mProgressMenu;

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getSupportMenuInflater().inflate(R.menu.share_public, menu);
		mProgressMenu = menu.findItem(R.id.refresh_loading);
		return true;
	}

	public void setLoadingState(boolean refreshing) {
		if (mProgressMenu != null) {
			if (refreshing) {
				mProgressMenu
						.setActionView(R.layout.actionbar_indeterminate_progress);
				mProgressMenu.setVisible(true);
			} else {
				mProgressMenu.setVisible(false);
				mProgressMenu.setActionView(null);
			}
		}
	}
现在根据刷新逻辑,只需调用setLoadingState方法就可以启用刷新动画了。


本项目不在 ActionView 中处理 OnClick 事件,用户点击该菜单是没响应的,采用此种方式,loading状态动画只会在刷新时进行,在刷新结束后隐藏。



注:本帖系在参考地址基础上改造,本项目使用了ActionbarSherlock来兼容3.0以下的版本中的Actionbar;

参考地址使用了AppCompat作兼容,在处理添加ActionView操作上略有不同。

参考地址Read more: http://blog.chengyunfeng.com/?p=572



【Codex教育管理系统】用班级设置维护教学班级层级数据 班级设置是教育管理系统中学生分班、行政班管理和选科走班的基础配置模块。它维护班级类型、年级分类、父子层级和启用状态,为学生管理、考试安排和班级分析提供统一班级口径。 阅读详情

相关推荐

Android代码-RefreshActionItem

RefreshActionItem An action bar item that implements this common pattern: Initially it shows a refresh button. If the button is clicked, a background operation begins and the button turns into a progress indicator. When the background operation ends, the button is restored to its initial state. The progress bar shows a magnitude which represents how far the operation has proceeded. The progress bar can also be made indeterminate, just like the built-in ProgressBar. It is possible to add a smal

android开发基础8-Action Bar的使用

action bar

blind cat 2645

MAPPO实战:从理论到代码的协作智能体训练指南

本文详细介绍了MAPPO算法在多智能体协作训练中的实战应用,从理论基础到代码实现全面解析。通过对比PPO与MAPPO的差异,深入讲解CTDE框架、网络架构设计、参数调优等关键环节,并提供实际项目中的调参经验和常见问题解决方案,帮助开发者快速掌握这一强化学习前沿技术。

weixin_42561040的博客 267

刷新按钮在actionbar上的效果

MenuItemCompat.setActionView(refreshItem, R.layout.actionbar_indeterminate_progress);

Sanjay的专栏 2631

fpga进阶--时序约束

1、基础概念 1.1 建立(setup)/保持(hold)时间 上述的锁存沿会将数据保存下来,但是必须要满足一定的条件: 建立时间Tsu:在时钟有效沿之前,数据必须保持稳定的最小时间; 保持时间Th:在时钟有效沿之后,数据必须保持稳定的最小时间; 1.2 亚稳态(Metastability) 亚稳态是由于违背了触发器的建立和保持时间而产生的,设计中任何一个触发器都有特定的建立和保持时间,在时钟上升沿前后的这段时间窗口内,数据输入信号必须保持稳定。如果信号在这段时间内发生了变化,那么输...

HHH的博客 2443

RK3588开发板RKNPU2环境部署实战:更新rknn_server与librknnrt.so详解

本文详细介绍了在RK3588开发板上更新rknn_server与librknnrt.so核心组件的完整实战流程。通过adb工具推送文件、设置权限并执行同步操作,确保RKNPU2环境部署成功,从而解决推理速度慢或初始化失败等问题,提升AI模型运行效率与稳定性。

weixin_29194817的博客 350

Android Studio 1.1.0 无法在ActionBar显示模糊进度条Indeterminate ProgressBar

代码都是一样。 public class MainActivity extends ActionBarActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         supportReq

raymond_lk的专栏 813

内网渗透(二)之基础知识-工作组介绍

在一个大型单位里,可能有成百上千台计算机互相连接组成局域网,它们都会列在"网络"(网上邻居)内。如果不对这些计算机进行分组,网络的混乱程度是可想而知的 为了解决这一问题,产生了工作组( Work Group)这个概念。将不同的计算机按功能(或部 门)分别列入不同的工作组,例如技术部的计算机都列入"技术部"工作组、行政部的计算机都 列入"行政部"工作组。要想访问某个部门的资源,只要在"网络"里双击该部门的工作组名 就可以看到该部门的所有计算机了。相比不分组的情况,这样的情况有序得多(尤其对大型局域网来说)。

把自己活成一道光,因为你不知道,谁会借着你的光,走出了黑暗。请保持心中的善良,因为你不知道,谁会借着你的善良,走出了绝望。请保持你心中的信仰,因为你不知道,谁会借着你的信仰,走出了迷茫。请相信自己的力量,因为你不知道,谁会因为相信你,开始相信了自己.... 1219

app_actionLayout定义的menu不能触发onOptionsItemSelected

UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!

2401_84132723的博客 723

YOLOv9改进策略【注意力机制篇】| 添加SE、CBAM、ECA、CA、Swin Transformer等注意力和多头注意力机制

这篇文章带来一个经典注意力模块的汇总,虽然有些模块已经发布很久了,但后续的注意力模块也都是在此基础之上进行改进的,对于初学者来说还是有必要去学习了解一下,以加深对模块,模型的理解。

Limiiiing的博客 2894

基于改进Unet的多场景水果图像分割与分类研究

本文针对复杂场景下的水果图像分割问题,提出了一种改进Unet模型。通过构建包含8类水果、3种成熟度及多种干扰场景的数据集,采用ResNet50与MobileNetV3作为骨干网络,并在跳跃连接层集成CBAM注意力机制。实验表明,改进模型在测试集上达到91.6%的mIoU,推理速度提升23%,特别在重叠水果和低光照场景表现突出。研究为农业视觉检测提供了有效解决方案。

AI的内部世界的博客 305

Android学习笔记之菜单详解

菜单概述每个Activity都可以指定它自己的菜单,按下硬件菜单键即可显示选项菜单。。但是从 Android 3.0(API 级别 11)开始,硬件菜单就变成了可选择的。Activity推荐使用应用栏和溢出菜单来代替传统的6键菜单。尽管某些菜单项的设计和用户体验已发生改变,但定义一系列操作和选项所使用的语义仍是以Menu API为基础。

rosy_dawn的博客 2838

如何为 Claude Code 配置代理与网络环境

那么大概率不是软件问题,而是。因为 Claude Code 是运行在终端里的,不是浏览器。

sg_knight的专栏 3485

JellyRefreshLayout XML属性速查表:jellyColor、pullHeight等5个参数一次讲透

JellyRefreshLayout 是一款 Android 下拉刷新布局库,用 Lollipop 时代的果冻回弹效果替代传统 Spinner 刷新头。本文以速查表形式,一次讲透 `jellyColor`、`headerHeight`、`pullHeight`、`triggerHeight` 以及加载文字等 5 个参数的含义、默认值与调参技巧,让你 3 分钟完成配置。 ## 30秒速查:5 个参

gitblog_00222的博客 899

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Android选项菜单(OptionsMenu)开发全指南

选项菜单(OptionsMenu)是Android应用开发中的核心交互组件,采用PopupWindow封装实现,通过Activity/Fragment生命周期自动管理显示逻辑。作为Material Design规范的标准元素,它解决了功能入口统一性与界面简洁性的平衡问题。开发者通过XML菜单资源文件定义结构,结合showAsAction属性控制项显示策略,利用onCreateOptionsMenu/onOptionsItemSelected实现声明式编程。在电商、社交等高频交互场景中,OptionsMenu

weixin_30363981的博客 504

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

安卓启动流程与期间核心组件工作原理

本文以实际工作中出现的启动相关各种千奇百怪的bug为钩子,讲解了安卓app冷启动过程中核心组件的工作原理,pms -> packageParser/androidmanifest.xml -> context -> ams -> application -> activity -> layoutInflater资源加载过程 -> wms /window/WM -> view与viewgroup绘制原理 -> 渲染阶段。理供解决问题的思路,看业务框架代码能看懂他们改的哪块源码,跟他们扯皮能扯赢

mix39的博客 337

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

android 应用启动出现actionbar 或者空白界面

以前在做一个应用的时候,启动会先出现actionbar一会

琪花亿草 8460

android 动态修改菜单,【Android】修改菜单

#Android Menu##菜单的回调时机常用的与菜单相关的主要有三个回调://创建菜单的时候调用public boolean onCreateOptionsMenu(Menu menu);//显示菜单的时候调用public boolean onPrepareOptionsMenu(Menu menu);//选择菜单项的时候调用public boolean onOptionsItemSelect...

weixin_42216454的博客 762

记录actionbar添加progressbar

 在Android新版本里,都是在actionbar上有progressbar 进度条。 @Override  public void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   pbLoading = new ProgressBar(getActivity());

lianyanni的专栏 690

Element-ui实现loading的局部刷新

&#13; &#13; 后台管理系统loading的局部刷新&#13; &#13;  &#13; 在一次vue+element-ui后台管理系统的项目中,遇到这样一个问题,引入element-ui加载框后,loading会占满整个屏幕,虽然通过改变路由实现了局部刷新,但是loading的全屏刷新,让人看上去很是不爽,以为是全局刷新。再一个问题就是,一个页面中可能含有的多个请求...

qq_41662119的博客 6000

自定义ActionBar盘点---------RefreshActionItem

带进度显示和刷新按钮的ActionBar 项目地址:https://github.com/ManuelPeinado/RefreshActionItem Demo地址:https://play.google.com/store/apps/details?id=com.manuelpeinado.refreshactionitem.demo APP示例:The New York Times

你不勇敢,\\没人替你坚强 452

android 按钮添加动画,给ActionBar中的按钮添加旋转动画(刷新动画)

经常看到很多应用会在Actionbar上放一个刷新按钮用来刷新页面内容,但是点击后并没有一个刷新的旋转动画,感觉少点什么,那我们就给它加一个旋转动吧!首先是菜单布局,有两个菜单,都设置成以Actionbar的方式显示,其中一个为刷新菜单:res/menu/main.xmlandroid:id="@+id/air_traffic"android:icon="@drawable/ic_action_a...

weixin_29271263的博客 559
上一篇: Android设计模式之Singleton单例模式
下一篇: 使用android.view.TouchDelegate扩大View的触摸点击区域
tongcpp
博客等级 码龄15年 32粉丝 23原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值