そして
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_dialog, container, false);
View tv = v.findViewById(R.id.text);
cl.seView (tv);
.....
}
をonCreatView LISTNERするビューを追加
class ChangeListener(){
TextView tv;
public setView(TextView view){
this.tv = tv;
}
public void onDataChange (String newData){
if(tv!=null){
tv.setText(newData);
}
}}
In Dialog:
@Override
public void onCreateDialog (Bundle savedInstanceStat){
cl = new ChangeListener();
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
cl.onDataChanged(snapshot.getValue());
}
}
を作成