开发学院手机开发Android 开发 Android线程间通信的Message机制 阅读

Android线程间通信的Message机制

 2010-06-01 15:44:00 来源:WEB开发网   
核心提示:39. btn.setOnClickListener(this);40. LinearLayout.LayoutParams param =41. new LinearLayout.LayoutParams(250,50);42. param.topMargin = 10;43. layout.addView(btn,

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 thread's 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.topMargin = 10;

75. layout.addView(tv, param2);

76. setContentView(layout);

77.

78. //主线程要发送消息给other thread, 这里创建那个other thread

79. receiveMessageThread = new ReceiveMessageThread();

80. receiveMessageThread.start();

81. }

82.

上一页  2 3 4 5 6 7 8 9 10 11 12  下一页

Tags:Android 线程 通信

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接