【转】在Series60中创建自定义列表(LISTBOX)

自定义控件——初识自定义控件 本文出自 “阿敏其人” 简书博客,转载或引用请注明出处。开发的时候,因为业务需求或者封装需要,我们会进行自定义控件。 说在前面,本篇涉及到一些东西 * onMeasure * onLayout * onDraw * MeasureSpec (32位二进制数,头两位模式(Mode),后两位大小(Size)) * onFinishInflate * ViewGr 阅读详情

原文:http://wiki.forum.nokia.com/index.php/%E5%9C%A8Series60%E4%B8%AD%E5%88%9B%E5%BB%BA%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%97%E8%A1%A8%28LISTBOX%29

 

在Series60中创建自定义列表(LISTBOX)

From Forum Nokia Wiki


适用版本:

S60 2nd Edition FP3, S60 3rd Edition


Image:CustomListbox.PNG


1.为什么要自定义 列表是在S60开发中经常用到的一个控件,在SDK中S60已经很周到的为我们提供了许多预定义的列表类型,其中包括 CAknSingleGraphicStyleListBox、CAknDoubleStyleListBox等,这些预定义列表基本能够满足开发的需 要。然而在一些特殊的场合下,自定义列表仍然有其用武之地,如使用自定义UI的应用程序中,比如在一些游戏中,使用自定义列表可以得到更好的用户体验。

2.如何自定义

2.1列表的MVC模型 在介绍具体的列表自定义方法之前有必要介绍一下列表模型的整体框架,列表使用的是我们常用的MVC模 型,即Model-View-Controller模型,其中Model模块用于处理数据存储,View模块是处理数据显示和UI,而 Controller则是用来联系两者的桥梁,通过Controller模块的CEikListBox::Model()可以得到Model,同样通过 CEikListBox::View()可以得到View。对于自定义列表来说,重点是View模块。 Image:MVC.PNG

2.2使用CListItemDrawer创建自定义列表 下面就可以开始创建自定义列表了,在开始之前我们还要弄清一件事:到底是由谁来完成数据显示的具体绘制工作的,我们可以通过CListBoxView::ItemDrawer()来得到这个对象,它是由CListItemDrawer类派生而来的一个实例。 下面的代码演示了如何从CListItemDrawer派生出自己的ItemDrawer:

      class CMyListItemDrawer: public CListItemDrawer

{

public:

CMyListItemDrawer(const CEikTextListBox& aListBox);

private: // CListItemDrawer

void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect, TBool aItemIsCurrent, TBool aViewIsEmphasized, TBool aViewIsDimmed, TBool aItemIsSelected) const;

private:

const CEikTextListBox& iListBox;

};

先来看一下构造函数完成了哪些工作吧:

        CMyListItemDrawer::CMyListItemDrawer(const CEikTextListBox& aListBox)

 :CListItemDrawer(),iListBox(aListBox)

{

// 设置图形上下文

iGc = &CCoeEnv::Static()->SystemGc();

SetGc(iGc);

}

在构造函数的参数中包含一个CEikTextListBox的引用,因为在ItemDrawer中要从CEikTextListBox中获得需要显示的文本。另外构造函数还设置了用来绘制列表的图形上下文(graphics context)iGc。

实际的绘制工作是在DrawActualItem这个函数中完成,通过对DrawActualItem、aItemIsSelected这些变量判 断当前绘制的是否具有焦点(Focus),然后根据情况来设置当前使用的字体以及画笔和背景的颜色,接着获取需要绘制的文本,这可以通过 iListBox.Model()来得到列表的Model,然后由ItemText()函数通过传入的列表项索引号得到,最后完成具体的绘制。下面的代码 给出了一个示范:

        void CMyListItemDrawer::DrawActualItem(TInt aItemIndex,

const TRect& aActualItemRect, TBool /*aItemIsCurrent*/,

TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,

TBool /*aItemIsSelected*/) const

{

.....

.....

// 设置绘制的字体,画笔式样和颜色等

const CFont* font = CEikonEnv::Static()->NormalFont();

iGc->UseFont(font);

iGc->SetPenColor(iTextColor);

iGc->SetPenStyle(CGraphicsContext::ESolidPen);

iGc->SetBrushColor(iBackColor);

iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);

// 绘制列表项

TPtrC itemText = iListBox.Model()->ItemText(aItemIndex);

TInt baseline = (aActualItemRect.Height() - font->HeightInPixels()) / 2+ font->AscentInPixels();

iGc->DrawText(itemText, aActualItemRect, baseline);

......

......

}

以上的步骤就完成了一个自定义的ItemDrawer的构建,通过改变iTextColor、iBackColor等变量的值我们可以得到自己满意的UI效果。

离成功只剩最后一步了,以上步骤完成了自定义的ItemDrawer,但是并没有告诉列表应该使用我们的ItemDrawer来完成列表的 绘制,这一步可以通过重载Controller模块的CEikTextListBox::CreateItemDrawerL()来完成:

        class CMyListBox: public CEikTextListBox

{

private: // from CEikTextListBox

virtual void CreateItemDrawerL()

{ iItemDrawer = new (ELeave) CMyListItemDrawer(*this); }

};

至此我们已经完成构建一个自定义列表的全部工作,其它的工作就交给系统去完成吧。

3.自定义列表的使用 对于自定义列表的使用与系统提供的其它列表的使用是相同的,以我提供的例子为例,首先创建一个自定义列表的实例

        // 创建一个自定义列表

iListBox = new (ELeave) CCustomListBox();

iListBox->ConstructL(this,CEikListBox::ENoFirstLetterMatching|CEikListBox::ENoExtendedSelection);

然后调用CTextListBoxModel::SetItemTextArray().来设置列表项:

        _LIT(KItemTextDouble1, "0/tFirst item/tDescription of the first item");

_LIT(KItemTextDouble2, "1/tSecond item/tDescription of the second item");

CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(2);

CleanupStack::PushL(array);

array->AppendL(KItemTextDouble1);

array->AppendL(KItemTextDouble2);

CleanupStack::Pop();

iListBox->Model()->SetItemTextArray(array);

在此有必要解释一下列表项的书写格式,此处是如下格式

        "0/tItem name/tDescription of the item"

与系统提供的书写方式一致,这么做并不是必须的,比如我们可以用"/b"代替"/t"作为分隔符,这样在程序中我们就要搜索"/b",而不是搜索"/t"。但是为了与系统保持一致,建议使用这种表示方式。

最后为自定义列表提供图标,如果没有图标显示,这一步可以省略,同时列表项的数据格式也会有所不同,其中的图标索引号就不再需要了,如下所示:

        "/tItem name/tDescription of the item"

      CArrayPtr<CGulIcon>* iconArray = new (ELeave) CArrayPtrFlat<CGulIcon>(2);

CleanupStack::PushL(iconArray);

CCustomListItemDrawer* itemDrawer = static_cast<CCustomListItemDrawer*>(iListBox->View()->ItemDrawer());

iconArray->AppendL(iEikonEnv->CreateIconL(KIconFileName, EMbmEikonFileclsd, EMbmEikonFileclsm));

CleanupStack::Pop(); // iconArray

itemDrawer->SetIconArray(iconArray); // 转移iconArray所属权

SetIconArray()函数会转移iconArray的拥有权(ownership);因此在此我们不用删除iconArray,CCustomListItemDrawer使用完毕以后会负责它的清除。

例子请到以下地址下载: [1]

本文参考antonypranata的Subclassing List Box in Symbian,在此表示感谢

C#上位机实战:基于.NET 8的智能车间监控系统,设备预警与故障诊断落地指南 协议适配是最耗时的环节,占整个项目工期的40%。不要低估现场设备的“个性”,预留充足的联调时间。不要过度设计。第一版用最简单的规则引擎就够了,等积累了足够数据再迭代。premature optimization是工控项目的大敌。跟现场师傅交朋友。他们脑子里的经验比任何文档都值钱,诊断规则的准确性完全取决于你从他们那里挖到了多少隐性知识。稳定性 > 功能丰富度。车间不需要花哨的3D可视化,需要的是7×24小时不死机、不漏报。每一行代码都要考虑异常路径。参考资料S7.Net Plus 官方文档。 阅读详情

相关推荐

工业互联网工控安全与工业质检AI大模型建设方案.pptx

工业互联网工控安全与工业质检AI大模型建设方案.pptx

Android自定义View的实现方法,带你一步步深入了解View(四)

不知不觉中,带你一步步深入了解View系列的文章已经写到第四篇了,回顾一下,我们一共学习了LayoutInflater的原理分析、视图的绘制流程、视图的状态及重绘等知识,算是把View中很多重要的知识点都涉及到了。如果你还没有看过我前面的几篇文章,建议先去阅读一下,多了解一些原理方面的东西。 之前我有承诺过,会在View这个话题上多写几篇博客,讲一讲View的工作原理,以及自定义View的方法。现在前半部分的承诺已经如约兑现了,那么今天我就要来兑现后面部分的承诺,讲一讲自定义View的实现方法,同时这也是带

郭霖的专栏 18万+

2024 《计算机网络》实验教学指导书.doc

2024 《计算机网络》实验教学指导书.doc

自定义控件---基础入门篇

Android系统内置了许多控件,如果这些控件不能满足需求,您可以自定义自己的控件,自定义的控件必须继承View类。 三种自定义控件的方式   按实现方式来划分的话,自定义View分为三种:自绘控件、组合控件、以及继承控件。 - 自绘控件:View上所展现的内容全部都是我们自己绘制出来的。此种方式也是最难的,一般会通过直接继承View类来实现自定义控件。 - 继承控件:如果对已有

阿姆斯特哩的博客 1535

1999年-2022年 上市公司-企业劳动生产率数据(原始数据、代码、最终结果、参考文献)

上市公司企业劳动生产率数据集为企业和市场参与者提供了一个深入分析企业生产效率和劳动效益的工具。通过这些数据,企业可以不断探索创新的发展模式和管理方式,努力提高生产效率,为提升市场竞争力和盈利能力做出贡献。数据名称:上市公司-企业劳动生产率数据数据年份:1999-2022年数据来源:国泰安数据库1999年-2022年 上市公司-企业劳动生产率数据(原始数据、代码、最终结果、参考文献)

2401_84585615的博客 881

NV 英伟达2022数字芯片笔试题

作者:数字IC打工人 链接:【开卷】第27期 NV 英伟达2022数字芯片笔试题_笔经面经_牛客网 来源:牛客网 1、Single Choice: Given thefollowing FIFO and rules, how deep does the FIFO need to be to preventunderflow or overflow? RULES: clk_A=25MHz; clk_B=100MHz; en_B is periodically asserted: period.

weixin_44072819的博客 6386

自定义控件

 转自:http://wiki.forum.nokia.com/index.php/%E5%9C%A8Series60%E4%B8%AD%E5%88%9B%E5%BB%BA%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%97%E8%A1%A8%28LISTBOX%29在Series60中创建自定义列表(LISTBOX)From Forum Nokia Wiki

ladliu的专栏 1261

ptrade量化策略之沪深300指数增强

本策略的核心是在沪深300股票池中选股,选择的股票都是市值比较大,业绩比较好的白马股,根据市场相对位置以及基本面因子来选择股票

qq_29301281的博客 1190

自定义控件其实很简单7/12

尊重原创转载请注明:From AigeStudio(http://blog.youkuaiyun.com/aigestudio)Power by Aige 侵权必究! 炮兵镇楼 要在数量上统计中国菜的品种,在地域上毫无争议地划分菜系,在今天,是一件几乎不可能完成的事……Cut…………抱歉……忘吃药了,再来一遍。如果非要对自定义控件的流程进行一个简单的划分,我会尝试将其分为三大部分:控件的绘制、控件的测

AigeStudio 3万+

Python爬虫博客:如何抓取时事新闻信息 —— 从各大新闻网站获取实时新闻数据

发送请求:向目标新闻网站发送 HTTP 请求,获取网页内容。解析网页:使用解析库(如)从网页中提取新闻标题、摘要、内容、发布时间等。绕过反爬虫机制:使用代理、设置请求头、模拟浏览器行为等策略绕过反爬虫技术。数据存储与清洗:将抓取的数据保存到本地文件或数据库中,并进行清洗,确保数据的可用性。在抓取过程中,我们还会面对很多实际问题,比如反爬虫技术、分页抓取、动态加载的内容等。接下来,我们将逐步介绍如何使用不同技术抓取静态和动态网页,并对抓取的内容进行处理。Scrapy。

2201_76125261的博客 2130

C#读取和写入excel表数据--手把手教详解

C#读写excel数据详解

如如水的博客 4054

在Series60中创建自定义列表(LISTBOX

<br /><br />)上一篇 / 下一篇  2009-04-17 03:53:38 <br /> <br />查看( 129 ) / 评论( 1 ) / 评分( 5 / 0 ) <br /> <br /> <br /> <br /> <br />1.为什么要自定义列表是在S60开发中经常用到的一个控件,在SDK中S60已经很周到的为我们提供了许多预定义的列表类型,其中包括CAknSingleGraphicStyleListBox、CAknDoubleStyleListBox等,这些预定义列表基本能够满足

World of iOs 638

C# 与蓝牙 BLE 设备通信:基于 Windows.Devices.Bluetooth 实现手环/传感器数据读取

本文介绍了如何利用C#的Windows.Devices.Bluetooth命名空间实现与蓝牙BLE设备的通信。首先概述了BLE技术特性及其在物联网中的应用场景,包括智能穿戴设备和传感器。随后讲解了BLE的GATT协议架构,解析了服务(Service)和特性(Characteristic)的概念。文章重点展示了通过C#实现设备扫描、连接、数据读取的完整代码示例,并详细说明了如何使用通知(Notifications)功能实现实时数据更新。最后提供了订阅心率测量特性变化的实现代码,为开发者提供了完整的BLE设备通

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1321

在Series60中创建自定义列表(LISTBOX)

在Series60中创建自定义列表(LISTBOX) 列表的MVC模型 在介绍具体的列表自定义方法之前有必要介绍一下列表模型的整体框架,列表使用的是我们常用的MVC模型,即Model-View-Controller模型,其中Model模块用于处理数据存储,View模块是处理数据显示和UI,而Controller则是用来联系两者的桥梁,通过Controller模块的CEikListBox::Mo

发芽的石头 803

直流无刷电机FOC控制算法 理论到实践 —— 理论(二)

在上一章节,我们对于FOC大体有了一个介绍,本博文将详细描述有关Clark变化、Park变化、反Park变化以及SVPWM的理论实现原理,也即相关数学运算实现。

爱出名的狗腿子 1万+

Win11 系统下 VisualStudio2022 配置点云库 PCL1.11.1

安装完成之后打开文件夹E:\PCL 1.11.1\3rdParty\OpenNI2双击 并选择路径 (E:\PCL 1.11.1\3rdParty\OpenNI2) 安装即可全部安装完成之后,将pcl-1.11.1-pdb-msvc2019-win64.zip解压后的 .pdb文件拷贝到(E:\PCL 1.11.1\bin)中设置环境变量:到此,环境变量配置完成。

qq_53545309的博客 1125

SymbianOS Series 60学习笔记二:ListBox控件

终于对Series?60的ListBox控件有了一个比较清晰的了解说真的这几天看这样的代码真有点赶鸭子上架我在放ListBox控件的容器类中声明了一个CEikColumnListBox*_listbox在其ConstructL函数中构造一个CEikColumnListBox的实例_listBox=new(ELeave) CAknSingleStyleListBox;_listBox->Const

hearme1的专栏 656

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

symbian在Series60中创建自定义列表(LISTBOX)

适用版本:S60 2nd Edition FP3, S60 3rd Edition1.为什么要自定义列表是在S60开发中经常用到的一个控件,在SDK中S60已经很周到的为我们提供了许多预定义的列表类型,其中包括CAknSingleGraphicStyleListBox、CAknDoubleStyleListBox等,这些预定义列表基本能够满足开发的需

1192

IMSL CNL 7.0.0 (x86-64)Crack

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

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

有关ListBox控件的一些总结

终于对Series 60的ListBox控件有了一个比较清晰的了解说真的这几天看这样的代码真有点赶鸭子上架我在放ListBox控件的容器类中声明了一个CEikColumnListBox* _listbox在其ConstructL函数中构造一个CEikColumnListBox的实例_listBox = new(ELeave) CAknSingleStyleListBox;_listBox->Con

天涯海角---专栏 456

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

Series 60 3rd---调整list box位置和大小后造成与scroll bar不一致的解决办法

 S60 2nd FP3以后标准控件中的scroll bar不再是屏幕下方的两个三角形了,而换成了类似Windows中scroll bar的样式,这种样式更直观,用户感觉确实更好.然而在移植一个项目到S60 3rd上时碰到了这个问题:调整list box位置和大小后造成与scroll bar不一致.比如:通过对list box调用SetExtent()使其不占满客户区,这时scroll bar的大

Beover1984(摇滚人生)的专栏 2614

Android自定义控件

开发自定义控件的步骤: 1、了解View的工作原理  2、 编写继承自View的子类 3、 为自定义View类增加属性  4、 绘制控件  5、 响应用户消息  6 、自定义回调函数  一、View结构原理 Android系统的视图结构的设计也采用了组合模式,即View作为所有图形的基类,Viewgroup对View继承扩展为视图容器

yfj710763925的专栏 1047

自定义控件其实很简单1/6

上一节我们粗略地讲了下如何去实现我们的View并概述了View形成动画的基本原理,这一节我们紧跟上一节的步伐来深挖如何去绘制更复杂的View! 通过上一节的学习我们了解到什么是画布Canvas什么是画笔Paint,并且学习了如何去设置画笔的属性如何在画布上画一个圆,然而,画笔的属性并非仅仅就设置个颜色、大小那么简单而画布呢肯定也不单单只是能画一个圆那么无趣,工欲善其事必先利其器,既然想画好图那必

AigeStudio 6万+

创建自定义控件

开发环境:jdk 1.8 + adt-bundle-windows-x86_64_20140101 提取码: j24g 运行环境:mumu模拟器 使用:adb_server connect 127.0.0.1:7555 1. 基础知识 在《第一行代码》中,该章节有张图,如下: 所有的控件都是直接或者间接的继承自View; 所有的布局都是直接或者间接的继承自ViewGroup; View也是V...

梦否 553
上一篇: 【转】Symbian UI 架构
下一篇: 【转】命令重定向操作符
code09
博客等级 码龄18年 31粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值