android Preference之android:dependency(列表依赖关系)

Android_Dependency的Jar包 Android PackageManager 有很多方法是没有暴漏出来的,我们如果想调用的话需 要用Java反射。android_dependency.jar 提供了反射调用相关的class定义,直接放到你的工程libs目录下面,然后就可以进行反射调用PackageManager的API。 立即下载

在开发软件设置界面的时候,我们可以采用android系统提供的PreferenceActivity来实现,下面给出一个简单的例子:

1.Activity代码如下:

[java]  view plain copy
  1. public class ConfigActivity extends PreferenceActivity {  
  2.     @Override  
  3.     public void onCreate(Bundle savedInstanceState) {  
  4.         super.onCreate(savedInstanceState);  
  5.         addPreferencesFromResource(R.xml.config);  
  6.     }  
  7.       
  8.     @Override  
  9.     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,  
  10.             Preference preference) {  
  11.         return super.onPreferenceTreeClick(preferenceScreen, preference);  
  12.     }  
  13. }  

2.Config.xml代码如下:


[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <PreferenceScreen  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.     <PreferenceCategory android:key="config" android:title="@string/config">  
  5.         <CheckBoxPreference android:key="config_anonymous"   
  6.             android:title="@string/config_anonymous"  
  7.             <strong><em>android:disableDependentsState="true"</em></strong>/>  
  8.         <EditTextPreference android:key="config_username"   
  9.             android:title="@string/config_username"  
  10.             <strong><em>android:dependency="config_anonymous"</em></strong>/>  
  11.         <EditTextPreference android:key="config_password"   
  12.             android:title="@string/config_password"  
  13.             <em><strong>android:dependency="config_anonymous"</strong></em>/>  
  14.     </PreferenceCategory>  
  15. </PreferenceScreen>  

3、实现的效果:


(解释:当上面的checkbox值为真,禁用下面的用户名和密码设置,否则开启下面的设置项)

 

4、关键点:

注意上面代码中的黑色粗体代码,android:dependency="config_anonymous"这个属性指定该设置项依赖于前面key="config_anonymous" 的CheckBoxPreference的值,

如果config_anonymous的值为真(即选中状态),则config_username和config_password可用,即enabled的,否则为disabled。

但是,现在的逻辑刚好相反,即config_anonymous的值为真的时候,需要禁用下面的config_username和config_password设置项。要实现这个就需要在CheckBoxPreference上设置了,

即添加android:disableDependentsState="true"这个属性,这个属性的意思是,当CheckBoxPreference的值为真的时候


原文:http://blog.youkuaiyun.com/hustpzb/article/details/6884782

白盒测试逻辑覆盖之谓词覆盖、子句覆盖、三类有效字句覆盖等知识点 本篇笔记会简化书本上的概念,用容易理解的方式来说明,有些例子打字麻烦,我会直接放图片! 目录 基础知识: 谓词覆盖predicate coverage 子句覆盖 clause coverage 组合覆盖 combinatorial coverage 有效字句覆盖Active Clause Coverage 广义有效子句覆盖(General Active Clause Coverage) 相关性有效子句覆盖(Correlated Active Clause Coverage) 限制性有效 阅读详情

相关推荐

步进电机 cia402协议 报文自己的理解 (笔记)

步进电机 cia402协议 报文自己的理解 (笔记)

she666666的博客 3811

Android dependency 监控实现

有时候第三方库改到了或者升级了,我们并不能及时发现,往往需要等到出问题的时候,去排查的时候,才发现是某个依赖版本改动导致的。当前本地分支落后远程分支, 且 local 分支有 commit 的时候,pull 或者 push 的时候,会产生一个 merge 节点,这时候 parent 会产生两个点,我们去 parent[1] 即可。然而这些情况就是我们往往所忽略的,即使有代码 review,有时候也会漏了。Gialab push 或者 merge 的时候,我们需要感知到,接着执行特定的 task,进行计算。

idaretobe的专栏 400

信贷风控分析—征信数据源

详解企业和个人征信报告,以及信贷风控之指标构造案例参考

csdnbt的博客 3642

Android——gradle插件配置方式——dependencies和plugins

我们知道Android studio 需要gradle插件进行构建和编译,随着AGP的升级,引入gradle插件也发生了变化。旧版本通过build.gradle文件中dependencies代码块引入,新版本通过plugins代码块引入

6739

第1章:Zephyr 开发环境搭建与 Hello World

📝【摘要】本文是Zephyr RTOS开发入门指南的第一章,详细介绍了从环境搭建到首个应用运行的完整流程。主要内容包括:1️⃣ Zephyr项目结构解析与west工具链部署;2️⃣ 开发环境配置(Linux/WSL)及SDK安装;3️⃣ 两种实践路径——官方HelloWorld样例与自定义应用开发;4️⃣ 实际硬件部署方法(nRF/STM32)及常用west命令速查;5️⃣ 典型问题解决方案。通过qemu_x86模拟器演示了基础打印功能实现,为后续深度开发奠定基础。

hemoparrot的专栏 1361

Qt 6.5实战:用QMediaPlayer搞定RTSP监控流播放(附LAV Filters解码器避坑指南)

本文详细介绍了如何在Qt 6.5中使用QMediaPlayer实现低延迟RTSP监控流播放,并提供了LAV Filters解码器的配置避坑指南。通过优化缓冲策略和硬件加速设置,显著提升视频流的播放性能和稳定性,适用于工业视觉检测和安防监控等实时场景。

weixin_33712987的博客 401

【Android studio】【Gradle】dependencies配置参数细解及异常解决

build.gradle配置中也许会有的疑惑。这里有答案

产品:SmartApi;服务:大前端++;其他技术分享 7209

XR Interaction Toolkit实战:为HTC Vive Cosmos打造抓取、投掷与UI交互(Unity 2023教程)

本文详细介绍了如何使用Unity 2023和XR Interaction Toolkit为HTC Vive Cosmos开发抓取、投掷与UI交互系统。通过实战案例'VR投掷训练室',从基础配置到高级功能实现,涵盖物理抓取、精准投掷机制和VR UI交互设计,帮助开发者提升VR交互开发技能。

weixin_30562507的博客 256

Android dependencies文件如何生成和查看

当需要排查包依赖冲突、统一依赖版本的时候,我们第一步要做的就是了解目前整个项目的依赖情况,Android dependencies文件就是所有模块在所有任务下的依赖情况综合(就是一个文件),比如App有编译时候的依赖图,也有执行时候的依赖图,本文就如何生成以及查看这个文件进行讲解。

xiaokangss的博客 1671

毕设加分项!手把手教你完成基于YOLOv8与PyQt5的多类别目标检测系统——让你的毕设从“完成”到“出色”

从KITTI数据集处理,到YOLOv8模型训练,再到PyQt5界面开发,整个流程其实没有想象中那么难。只要你跟着步骤一步步来,不仅能顺利完成毕设,还能掌握目标检测和GUI开发的核心技能——这些技能在未来的求职、读研中都非常实用。如果过程中遇到问题,别担心!可以去YOLOv8的官方文档、PyQt5论坛找答案,也可以和同学、老师交流。记住,完成毕设的过程也是你技术成长的过程,坚持下去,你会为自己的成果感到自豪。

m0_71589036的博客 179

Pandas滚动窗口的妙用:动态计算列数据的最大值

Pandas的滚动窗口(rolling window)功能是数据分析中处理时间序列数据的重要工具。本文通过实例演示了如何使用rolling(window=4).max()计算DataFrame列A的滚动最大值,并将结果存入新列Max_Range。该方法会在4个元素的滑动窗口内计算最大值,前3行因数据不足显示为NaN。这种技术广泛应用于金融分析(如股价波动)、数据平滑和趋势识别等场景,能有效帮助分析数据的动态变化特征。示例展示了从数据准备到结果输出的完整流程,体现了Pandas在处理滑动窗口计算时的高效性和便

m0_74337424的博客 53

PreferenceScreen的属性android:dependency的用法

当CheckBoxPreference没有被选中后,想使后面的控件不可点击就可以用到这个属性。样子如下: 如果相反,当第一个被选中,第二个不点击,可以参考下面的一篇文章。转载地址:http://aswang.iteye.com/blog/1073946。备注:它的xml文件我导入eclipse有问题。不过可以参考它的思路。 android Preference之android:d...

weixin_30439067的博客 200

详解大端模式和小端模式

详解大端模式和小端模式 一、大端模式和小端模式的起源         关于大端小端名词的由来,有一个有趣的故事,来自于Jonathan Swift的《格利佛游记》:Lilliput和Blefuscu这两个强国在过去的36个月中一直在苦战。战争的原因:大家都知道,吃鸡蛋的时候,原始的方法是打破鸡蛋较大的一端,可以那时的皇帝的祖父由于小时侯吃鸡蛋,按这种方法把手指弄破了,因此他的父亲,就下令,命令

ce123的技术博客 19万+

Android设置页面开发:从Preference到DataStore的现代化实践

在Android应用开发中,应用配置管理是基础且关键的功能模块,它直接关系到用户体验和数据持久化。其核心原理是通过一套声明式的UI框架,将界面元素、用户交互与数据存储自动绑定,实现高效的配置管理。这一技术方案的价值在于,它极大地减少了开发者处理设置页面的重复性工作,提升了代码的可维护性和架构清晰度。典型的应用场景包括应用内的各种开关、输入框、列表选择等用户偏好设置。随着Jetpack组件库的演进,Preference框架与DataStore的结合,为开发者提供了更现代化、类型安全且支持响应式编程的解决方案。

weixin_30876945的博客 485

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Preference -- dependency 和 disableDependentsState属性 小结

Preference -- dependency 和 disableDependentsState属性 小结 2013-01-18 15:37 3228人阅读 评论(0) 收藏 举报  分类: android之Preference(7)  android-源码开发(83)  版权声明:本文为博主原创文章,未经博主允许不得转载。 http://b

王人冉的博客 813

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

android Preference之android:dependency

在开发软件设置界面的时候,我们可以采用android系统提供的PreferenceActivity来实现,下面给出一个简单的例子:   1、Activity 代码如下:     Java代码   public class ConfigActivity extends PreferenceActivity {       @Override    

莹波&微步 1368

深度学习工具包 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")

0803-APP-Preference-dependency

介绍android:dependency

zhi07的专栏 487

Android preference XML Attributes

Android preference XML Attributes 说明Preference元素的通用XML Attributes说明: android:key : 每个Preference控件独一无二的”ID”,唯一表示此Preference。 android:defaultValue : 默认值。 例如,CheckPreferenc

wangjicong_215的博客 623

Android 中Preference作为布局的应用

java.lang.Object    ↳ java.util.prefs.Preferences 目前在Android系统源码中,Setting模块中使用的就是Preference布局,而不是常用的View布局结构。现在我们来学习Preference在布局中的应用。 Preference 控件 它的应用效果与TextView 有点相似。但是使用方法却完全不

yuminfeng728的博客 2627

实例探索Preference XML文件中的各项属性

Preference的API中定义了如下属性,我们通过实例一一分解它们的含义和用处。本例借助一个CheckBoxPreference分析,而且只分析Preference里的各项属性,对于子类的属性我们这里不作介绍。 MainActivity.java: package com.sean.preferenceattributestest; import android.app.Ac

sean_xiang的专栏 3025

Andorid Preference -- dependency 和 disableDependentsState属性 小结

1.Activity代码如下: public class ConfigActivity extends PreferenceActivity {       @Override       public void onCreate(Bundle savedInstanceState) {           super.onCreate(savedInstanceState

FL1623863129的博客 756

Android中preference的使用(二)

继上篇文章 Android中preference的使用(一) ,在这篇文章中主要是学习下preference中各个节点的属性。PrefeneceActivity都提供了哪几种元素可供使用。点击Add按钮,在打开的新窗口中可以看到以下几项: 1. CheckBoxPreference:CheckBox选择项,对应的值的ture或flase。如图: 2. EditTextP

u014412834的专栏 522
上一篇: android-arm-eabi-addr2line工具
下一篇: 使用 Eclipse Memory Analyzer 进行堆转储文件分析
jacklce
博客等级 码龄15年 18粉丝 26原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值