我应该使用哪种函数从firebase检索数据到标签的正确语法是什么?
例如,我想将电子邮件和密码检索为in the picture here
我试过这个代码,但它没有用!它在模拟器中找不到任何东西!!
public class MySurfaceThread extends AsyncTask<Void, Void, Void> {
SurfaceHolder mSurfaceHolder;
CustomSurfaceView cSurfaceView;
public MySurfaceThread(SurfaceHolder sh, CustomSurfaceView csv) {
mSurfaceHolder = sh;
cSurfaceView = csv;
x = y = 0;
cSurfaceView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
x = event.getX();
y = event.getY();
calculateValues(x, y);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
x = y = 0;
dx = dy = 0;
break;
case MotionEvent.ACTION_CANCEL:
break;
case MotionEvent.ACTION_MOVE:
break;
}
return true;
}
private void calculateValues(float xx, float yy) {
dx = xx - zeroX;
dy = yy - zeroY;
angle = (float)Math.atan(Math.abs(dy/dx));
hyp = (float)Math.sqrt((dx * dx) + (dy * dy));
if(hyp > radius) {
if(dx > 0 && dy > 0){ //bottom right
xx = (zeroX + (radius*(float)Math.cos(angle)));
yy = (zeroY + (radius*(float)Math.sin(angle)));
}
else if(dx > 0 && dy < 0){ //top right
xx = (zeroX + (radius*(float)Math.cos(angle)));
yy = (zeroY - (radius*(float)Math.sin(angle)));
}
else if(dx < 0 && dy < 0){ //top left
xx = (zeroX - (radius*(float)Math.cos(angle)));
yy = (zeroY - (radius*(float)Math.sin(angle)));
}
else if(dx < 0 && dy > 0) { //bottom left
xx = (zeroX - (radius*(float)Math.cos(angle)));
yy = (zeroY + (radius*(float)Math.sin(angle)));
}
}
else {
xx = zeroX + dx;
yy = zeroY + dy;
}
x = xx;
y = yy;
}
});
}
@Override
protected Void doInBackground(Void... params) {
Canvas canvas = null;
while (running) {
try {
canvas = mSurfaceHolder.lockCanvas();
synchronized (mSurfaceHolder) {
zeroX = canvas.getWidth()/2;
zeroY = canvas.getHeight()/2;
cSurfaceView.onDraw(canvas, x, y, zeroX, zeroY);
}
Thread.sleep(10);
} catch (InterruptedException e) {
} finally {
if (canvas != null) {
mSurfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
return null;
}
}
答案 0 :(得分:1)
试试这个
var ref = Firebase(url:"YOUR_URL_PATH/Users")
ref.observeEventType(.Value, withBlock: { snapshot in
let m = snapshot.value.objectForKey("Email")as?
self.EmailLabel.text = m
}, withCancelBlock: { error in
println(error.description)
})
希望这会对你有帮助......