我想显示通过查询得到的listview
中的ArrayList
。
尽管ArrayList pt in addValueEventListener
被声明为静态属性,但null
成为addValueEventListener之外的ArrayList
。
有没有办法在ArrayList
eventlistener?
的值
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot!=null) {
Log.e("TAG", String.valueOf(dataSnapshot.child("uid").child("Name")));
int i=0;
for(DataSnapshot snapshot : dataSnapshot.getChildren()){
String userName = snapshot.child("Name").getValue(String.class);
Pt.add(userName);
//Toast.makeText(getApplicationContext(), dataSnapshot.toString(), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getApplicationContext(), "Datasnapshot is null", Toast.LENGTH_SHORT).show();
}
}
答案 0 :(得分:0)
尝试此代码。
this.mouseCapture.acquire(evt, {
mouseMove: () => {
if (!dragging) {
let x1 = Math.abs(evt.pageX - x);
let y1 = Math.abs(evt.pageY - y);
if (x1 > this.threshold || y1 > this.threshold) {
dragging = true;
if (config.dragStarted) {
config.dragStarted(x, y, evt);
}
if (config.dragging) {
// First 'dragging' call to take into account that we have
// already moved the mouse by a 'threshold' amount.
config.dragging(evt.pageX, evt.pageY, evt);
}
}
} else {
if (config.dragging) {
config.dragging(evt.pageX, evt.pageY, evt);
}
x = evt.pageX;
y = evt.pageY;
}
},
mouseUp: () => {
console.log('dragging.service.ts : mouseUp');
this.mouseCapture.release();
evt.stopPropagation();
evt.preventDefault();
},
released: () => {
console.log('dragging.service.ts : released');
if (dragging) {
if (config.dragEnded) {
config.dragEnded();
}
} else {
if (config.clicked) {
config.clicked();
}
}
},
});
答案 1 :(得分:0)