Listener by value

   Recently engaged in a plurality of Bluetooth devices functionally connected device obtains measured values ​​of each fragment shown in EditText;

   I was in the form of static variables passed by value. The result was the boss said of the meal, he said, the measured value Bluetooth is bound to change, then there will be a listener by value. . . The main method used is setXueYaValue () method:

   In which a Bluetooth device inside the class:

public String valueXYsuo; // systolic blood pressure 
public String valueXYzhang; // diastolic blood pressure
private XYChange xychangeListener= null;
public void setXychangeListener(XYChange xychangeListener) {
this.xychangeListener = xychangeListener;
}
public void setXY(String XYsuo,String XYzhang) {
if(this.valueXYsuo.equals(XYsuo)) {
return ;
}
this.valueXYsuo = XYsuo;
this.valueXYzhang = XYzhang;
if (this.xychangeListener != null) {
this.xychangeListener.XTChange(XYsuo,XYzhang);
}
}
在蓝牙拿到值得那个地方引用setXY()方法即可。

And then create XYChange () Interface:
interface XYChange {public 
void XTChange (valueSuo String, String valueZhang);
}
finally implement this interface in your fragment and obtain values which can be friends.

Guess you like

Origin www.cnblogs.com/dmrbell/p/11493784.html