标签:read span 请求 ble oid details convert public string
一、回调机制概述
public interface CallBack { public void solve(int result); }
public class StudentA implements CallBack{ private StudentB mStuB; public StudentA(StudentB mStuB){ this.mStuB = mStuB; } public void askQuestion(final int a,final int b){ new Thread(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub mStuB.executeMessage(StudentA.this, a, b); } }).start(); } @Override public void solve(int result) { // TODO Auto-generated method stub System.out.println(result); } }
(3)Class B的实现
public class StudentB { public void executeMessage(CallBack callBack,int a,int b){ System.out.println("A的问题是:"+a +" + "+ b+"=?"); int result = a + b; callBack.solve(result); } }
(4)值的初始化
public class CallBackTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int a = 1; int b = 1; StudentB mStuB = new StudentB(); StudentA mStuA = new StudentA(mStuB); mStuA.askQuestion(a,b); } }
标签:read span 请求 ble oid details convert public string
原文地址:http://www.cnblogs.com/Daniel-android/p/6249443.html