关于Only the original thread that created a view hierarchy can touch its views的解决方案

【学习体会】Lighttools8.4.0:软件基本使用+光度学基本概念+系统初始设置 关于Lighttools8.4.0软件的安装教程,详见我的另一篇博文:【软件安装】win10下Lighttools8.4.0(64)光学系统建模软件的安装教程 在本文中,我们将学习到,光度学的基本概念、系统初始设置、物体模型坐标的使用方法、简单光学系统实例、系统浏览器的作用和内容、设置虚拟相机并渲染视图中的图像、仿真结果3D显示等。 如果有其他感兴趣的内容但是我又没有写的,欢迎在评论区留言! 光度学的基本概念 软件的基本介绍 参考博文:https://www.docin.c... 阅读详情

转自:http://www.cnblogs.com/king_dy/archive/2010/11/27/1889444.html

        我表示很头疼,碰到这个问题,丝毫不晓得哪里出了问题。但问题必须得解决,硬着头皮一点一点试,总觉得跟线程有关系,不停的换关键词baidu,google各种搜索,最终,发现问题的所在。

        我所做的游戏游戏画面用的是GL绘制,而今天我要添加的mobclix确是一个view控件,而view和控件不是线程安全的,而控制控件的view是主线程(个人理解,获取不大准确,从问题翻译上分析得到),要想控制主线程改变view,必须得以主线程的身份。而如何让主线程知道我要改变它呢,就要用到Handler类了。。

	private static Handler mHandler = new Handler(){ 
	    public void handleMessage(Message msg)
	    {
	        if(msg.what == 0)
	        {
	            layout.setVisibility(View.GONE);
	        }
	        else if(msg.what == 1)
	        {
	            layout.setVisibility(View.VISIBLE);
	        }
	    }
	};

当需要让主线程view作出改变时,只需调用

mHandler.sendEmptyMessageDelayed(args, 0);

华为OD干了两个月,还是跑了 ​本人工作了快13年,base南京。2024年2月份由于公司业务变动第一次拿到了公司发的大礼包,同时也面临着失业的问题,我对自己的技术还是很有信心的,但是,找了大概有一个多月时间,发现心意的工作的确不太好找,当然收到挺多家offer,就是薪资不太满意,外包也一直不想去,不过说实话外包给的薪资普遍要比自研的单位要高一些,最后为了钱还是进华为(既然选择外包那就选择好一些的吧),毕竟中年老男人工作不能断太久。 阅读详情

相关推荐

医学影像处理实战:用SimpleITK将CT数据重采样到统一尺寸(附完整代码)

本文针对医学影像分析中多源CT数据尺寸不一致导致深度学习模型训练失败的问题,提供了基于SimpleITK的实战解决方案。通过深入解析图像尺寸与间距的关系,详细阐述了如何通过调整体素间距进行重采样,而非简单补零,从而在保持图像物理尺寸不变的前提下,将数据统一到固定尺寸,确保输入网络的3D数据空间对齐且解剖信息准确。

weixin_29062671的博客 270

Only the original thread that created a view hierarchy can touch its views.

场景: 项目开发中会涉及到一些耗时操作,这个时候就会开启一个子线程,将耗时操作放到子线程中取操作,操作完毕后,往往还要同步更新ui,这个时候如果直接在子线程中更新ui,将会导致程序的闪退,同时还会看到 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a

wangwo1991的博客 8195

深入解析数据通信中的码元速率与比特率:从基础到实战应用

本文深入解析了数据通信中的核心概念码元速率与比特率,通过生动的比喻和公式(比特率=波特率×log₂(M))揭示其本质关系。文章结合BPSK、QPSK、16QAM等调制技术,剖析了从4G/5G到LoRa等实战场景中如何权衡速率、距离与可靠性,并提供了软考真题解析与系统设计建议,帮助读者从理论到应用全面掌握数据速率优化。

weixin_29324877的博客 213

Only the original thread that created a view hierarchy can touch its views

解决Only the original thread that created a view hierarchy can touch its views 很多网友在Android中使用多线程处理UI相关内容时可能会发现Logcat提示Only the original thread that created a view hierarchy can touch its vie

breeze666的专栏 8万+

3D打印必备:如何用Blender将NWD文件转成STL(附精度调整技巧)

本文详细介绍了如何使用Blender将NWD文件转换为STL格式,特别针对3D打印需求提供了精度调整技巧。从环境准备到分步转换流程,再到3D打印专属优化策略,帮助设计师解决破面、尺寸偏差等常见问题,实现高效、精准的格式转换。

week9的博客 272

数字IC笔记-低功耗技术

传统的降低Power的方法主要有: 1.门控时钟技术(clock gating) 2.多阈值电压技术(MultiShreshold) 3.动态电压频率调节技术(DVFS) 目前有以下几种低功耗技术: 1.多电压技术(Multi-Voltage) 2.MTCOMS Power Gating 技术(多阈值功耗控制技术),比如基带部分中的2G、3G、CDMA、LTE等通过awake—>sleep—>awake的方式间歇式的打开或关断其电源,power gating 可以完全关掉dynamic的pow

sinat_41774721的博客 1932

解决Only the original thread that created a view hierarchy can touch its views

Only the original thread that created a view hierarchy can touch its views 出现原因:回调接口在子线程,并在回调接口对UI进行了操作 所以,将会出现上述提示 一般来讲,会使用handle解决这个问题 在对应的回调接口根据网络请求返回的数据来传递不同的消息 handler.sendMessage(msg); 再根据消息的内容...

i_nclude的博客 3万+

RU.EXE实用指南:从基础操作到高级调试技巧

本文是RU.EXE(RW Everything)的实用指南,详细介绍了这款硬件调试工具从基础操作到高级技巧的全过程。文章阐述了RU.EXE作为直接读写硬件寄存器、内存和PCI配置空间的强大工具,如何帮助硬件工程师和开发人员高效进行底层系统调试与故障排查,并强调了安全操作的重要性。

weixin_29228203的博客 278

android开发 bug问题解决:Only the original thread that created a view hierarchy can touch its views

android开发 bug问题解决:Only the original thread that created a view hierarchy can touch its views. 翻译:只有创建视图层次结构的原始线程才能触及其视图。(意思就是在异步线程中不能更新主线程UI) 解决办法之一 创建一个handler去更新UI线程 代码实现 1、handler处理返回数据请求,并更新数据到...

七夜的博客 5287

【0000】PostgreSQL V17.4 内核源码剖析专栏(2017 ~ 2025.11.28 更新)

本专栏将会持续更新,直到将PostgreSQL V13.2源码涉及的所有原理、技术剖析完成为止。每一篇文章都是经过多次的源码阅读 + 调试,得以验证之后才梳理成文章形式。最终该专栏的文章数量应该在一万篇或以下,这也是文章序号从【0000】开始的缘故。通过本专栏的学习,能够让你掌握PostgreSQL数据库中的每个技术背后,底层的实现原理。

Postgres 数据库内核开发工程师 1万+

Gromacs 模拟昆虫 P450 解毒酶与农药结合完整指南,仅供参考!

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 1240

Only the original thread that created a view hierarchy can touch its views错误

Only the original thread that created a view hierarchy can touch its views错误

码夫的专栏 3195

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

only the original thread that created a view hierarchy can touch its views解决方案

Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 此错误是在非UI线程中更新UI所造成的,解决方案如下: private class LongTim

viz 2188

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

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Only the original thread that created a view hierarchy can touch its views的解决方案

要想控制主线程改变view,必须得以主线程的身份。而如何让主线程知道我要改变它呢,就要用到Handler类了。。 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 private static Handler mHandler = new Ha

Devil不加V 1300

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Only the original thread that created a view hierarchy can touch its views:

报错:Only the original thread that created a view hierarchy can touchits views:        原因:在非主线程中了进行了操作UI线程(主线程)中比如:UI更新的操作。导致的报错        解决方法:使用handler 或者asynctask等方法

奋斗的IT小民工的博客 1576

android中出现Only the original thread that created a view hierarchy can touch its views.错误解决方案

/** * kill the process onclick listener * @param view */ public void killProcess(View view){ int total = 0; long memorySize = 0; for (TaskInfo userTaskInfo : usertaskinfos) { if(userTa

lg878398509的专栏 1798

用Vue CLI仿写饿了么:从工程搭建到移动端交互实战

前端工程化实践是衡量开发者综合能力的重要标准。Vue CLI作为成熟的构建工具,不仅提供规范的目录结构,还通过webpack配置实现Mock接口与代码拆分。在移动端场景中,状态管理和复杂交互往往成为项目瓶颈。以仿写饿了么为切入点,系统讲解如何利用Vue CLI搭建项目骨架,通过Vuex管理购物车数据流,借助better-scroll实现双栏滚动联动,并处理弹层穿透与路由缓存等细节。从接口封装到打包部署,覆盖完整开发链路,帮助开发者建立从技术选型到工程落地的全局思维,为简历增添有说服力的实战项目经验。

weixin_33851177的博客 255

android异常:android.view.ViewRootImpl$CalledFromWrongThreadException

android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 出现这个异常的原因是你在子线程中修改了主线程中的组件的状态或数据。 android规定:只有在原始线程中(主

宏亮的专栏 7172

Handler Runnable Message

[Android]:Only the original thread that created a view hierarchy can touch its views异常处理思路  :http://blog.sina.com.cn/s/blog_8401d4020100spss.html http://blog.youkuaiyun.com/djx123456/article/details/632598

iloveaman的专栏 710

Android 线程异常报错

android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 出现这个异常的原因是你在子线程中修改了主线程中的组件的状态或数据。 android规定:只有在原始线程中(主

tanghua0809的专栏 1013
上一篇: 关于android工程中R.java不自动生成的问题
下一篇: ANDROID关于亮屏和暗屏还有解锁的监听事件http://blog.youkuaiyun.com/muskmelon123/article/details/7522023
SingingCoder
博客等级 码龄15年 9粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值