Android狼双岻Message字崙議痩試哘喘

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 17:02 点击:

和中厘断氏參android糞箭栖婢幣斤哘議孔嬬?殻會順中噐和?

Android狼双岻Message字崙議痩試哘喘

  殻會旗鷹泌和?朔中何蛍嗤旗鷹傍苧?

 1 package com.android.messageexample;  
 2 import android.app.Activity;  
 3 import android.content.Context;  
 4 import android.graphics.Color;  
 5 import android.os.Bundle;  
 6 import android.os.Handler;  
 7 import android.os.Looper;  
 8 import android.os.Message;  
 9 import android.util.Log;  
 10 import android.view.View;  
 11 import android.view.View.OnClickListener;  
 12 import android.widget.Button;  
 13 import android.widget.LinearLayout;  
 14 import android.widget.TextView;  
 15  public class MessageExample extends Activity implements OnClickListener {  
 16 private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;  
 17 private final int FP = LinearLayout.LayoutParams.FILL_PARENT;  
 18 public TextView tv;  
 19 private EventHandler mHandler;  
 20 private Handler mOtherThreadHandler=null;  
 21 private Button btn, btn2, btn3, btn4, btn5, btn6;  
 22 private NoLooperThread noLooerThread = null;  
 23 private OwnLooperThread ownLooperThread = null;  
 24 private ReceiveMessageThread receiveMessageThread =null;  
 25 private Context context = null;  
 26 private final String sTag = "MessageExample";  
 27 private boolean postRunnable = false;  
 28  
 29 /** Called when the activity is first created. */ 
 30 @Override 
 31 public void onCreate(Bundle savedInstanceState) {  
 32    super.onCreate(savedInstanceState);  
 33    context = this.getApplicationContext();  
 34    LinearLayout layout = new LinearLayout(this);  
 35    layout.setOrientation(LinearLayout.VERTICAL);  
 36    btn = new Button(this);  
 37    btn.setId(101);  
 38    btn.setText("message from main thread self");  
 39    btn.setOnClickListener(this);  
 40    LinearLayout.LayoutParams param =  
 41     new LinearLayout.LayoutParams(250,50);  
 42    param.topMargin = 10;  
 43    layout.addView(btn, param);  
 44    btn2 = new Button(this);  
 45    btn2.setId(102);  
 46    btn2.setText("message from other thread to main thread");  
 47    btn2.setOnClickListener(this);  
 48    layout.addView(btn2, param);  
 49    btn3 = new Button(this);  
 50    btn3.setId(103);  
 51    btn3.setText("message to other thread from itself");  
 52    btn3.setOnClickListener(this);  
 53    layout.addView(btn3, param);  
 54    btn4 = new Button(this);  
 55    btn4.setId(104);  
 56    btn4.setText("message with Runnable as callback from other thread to main thread");  
 57    btn4.setOnClickListener(this);  
 58    layout.addView(btn4, param);  
 59    btn5 = new Button(this);  
 60    btn5.setId(105);  
 61    btn5.setText("main threads message to other thread");  
 62    btn5.setOnClickListener(this);  
 63    layout.addView(btn5, param);  
 64    btn6 = new Button(this);  
 65    btn6.setId(106);  
 66    btn6.setText("exit");  
 67    btn6.setOnClickListener(this);  
 68    layout.addView(btn6, param);  
 69    tv = new TextView(this);  
 70    tv.setTextColor(Color.WHITE);  
 71    tv.setText("");  
 72    LinearLayout.LayoutParams param2 =  
 73      new LinearLayout.LayoutParams(FP, WC);  
 74    param2.to

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Android 完全退出程序
      • 原创:Android应用开发-Andorid歌词秀,含源码
      • android 屏幕保护
      • Android手机软件汉化教程---第四课 dex文件汉化
      • 众多Android 开源项目推荐,给力工作给力学习
      • Android Audio代码分析4
      • Android得到已安装的应用程序信息!
      • Android开发者指南(29) —— USB Host and Accessory
      • Android成长的幕后推手:工程师鲁宾
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1