There is no real difference, except that the View.post is helpful when you don't have a direct access to the activity.

    public boolean post(Runnable action) {
Handler handler;
if (mAttachInfo != null) {
handler = mAttachInfo.mHandler;
} else {
// Assume that post will succeed later
ViewRoot.getRunQueue().post(action);
return true;
} return handler.post(action);
}
    public final void runOnUiThread(Runnable action) {
if (Thread.currentThread() != mUiThread) {
mHandler.post(action);
} else {
action.run();
}
}

Activity # runOnUiThread 与 View # post的更多相关文章

  1. Handler具体解释系列(七)——Activity.runOnUiThread()方法具体解释

    MainActivity例如以下: package cc.testui3; import android.os.Bundle; import android.view.View; import and ...

  2. android Activity runOnUiThread() 方法的使用

    利用Activity.runOnUiThread(Runnable)把更新ui的代码创建在Runnable中,然后在需要更新ui时,把这个Runnable对象传给Activity.runOnUiThr ...

  3. android Activity runOnUiThread() 方法使用

    在android 中我们一般用 Handler 做主线程 和 子线程 之间的通信 . 现在有了一种更为简洁的写法,就是 Activity 里面的 runOnUiThread( Runnable )方法 ...

  4. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L ...

  5. 理解Activity.runOnUiThread()

    这是一篇译文(中英对照),原文链接:Understanding Activity.runOnUiThread() When developing Android applications we alw ...

  6. Android 开发 Activity里获取View的宽度和高度 转载

    原文地址:https://blog.csdn.net/chenbaige/article/details/77991594 前言: 可能很多情况下,我们都会有在activity中获取view 的尺寸大 ...

  7. activity.runOnUiThread()内的run()方法没有被执行

    activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(context, toast, Toast.LEN ...

  8. Activity中获取view的高度和宽度为0的原因以及解决方案

    在activity中可以调用View.getWidth.View.getHeight().View.getMeasuredWidth() .View.getgetMeasuredHeight()来获得 ...

  9. Activity,Window,View之间是什么关系?

    Activity在onCreate之前调用attach方法,在attach方法中会创建window对象.window对象创建时并没有创建 Decor对象对象.用户在Activity中调用setCont ...

随机推荐

  1. iOS开发之使用XMPPFramework实现即时通信

    iOS开发之使用XMPPFramework实现即时通信   关于XMPP的理论介绍在本篇博客中就不做赘述了,如何在我们之前的微信中加入XMPP协议来实现通信呢?下面将会介绍一下XMPP的基本的知识,让 ...

  2. linx 设备名字来由 sd sr sg st

    转载保留:http://blog.csdn.net/luoweifeng1989/archive/2011/05/17/6426193.aspx 一直不知道 sda sdb sr0 这些名字的前两两个 ...

  3. 让超出DIV宽度范围的文字自动显示省略号...

    关键是:text-overflow: ellipsis; div.titleholder { font-family: ms sans serif, arial; font-size: 8pt; wi ...

  4. UVALive 7712 Confusing Manuscript 字典树 查询与s的编辑距离为1的字符串数量

    /** 题目:UVALive 7712 Confusing Manuscript 链接:https://vjudge.net/problem/UVALive-7712 题意:给定n个不同的字符串,f( ...

  5. .NET开发笔记--对config文件的操作(3)

    1.添加新节点前进行判断看是否已存在相同的属性值,若存在进行更新,不存在则进行添加操作. protected bool AddPizza() { //初始化id int newId; string f ...

  6. 网页(aspx)与用户控件(ascx)交互逻辑处理实现

    几个页面(ASPX)都使用一些相同的控件,一个文本框,二个按钮(搜索和导出),为了以后好维护,把这相同的部分抽取放在一个用户控件(ASCX)上.现需要处理逻辑如下 搜索事件处理的逻辑在各个页面处理. ...

  7. VC++ Debug显示指针所指的array内容

    If you expand a pointer and you only get a single item, just add ",n" to the entry in the ...

  8. 好用的 Visual Studio插件

    Image Optimizer(图片优化)插件 使用行业标准优化任何JPEG,PNG和gif(包括动画gif).可以做有损和无损的优化.

  9. 62、常规控件(5)Navigation View –美观的侧滑视图

    1.main_layout.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.andr ...

  10. 基础知识《十三》深入浅出Java回调机制

    本文转载自http://hellosure.iteye.com/blog/1130176 在网上看到了一个比喻,觉得很形象,这里借用一下: 你有一个复杂的问题解决不了,打电话给你的同学,你的同学说可以 ...