dataku.java
package com.example.w8.datasiswa;
public class dataku {
private String nama;
private String telp;
public dataku() {
}
public dataku(String nama, String telp){
this.nama=nama;
this.telp=telp;
}
public String getNama() {return nama;}
public String getTelp() {return telp;}
}
MainActivity.Java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Firebase.setAndroidContext(this);
}
@Override
protected void onStart() {
super.onStart();
final Firebase ref = new Firebase("https://datasiswa.firebaseio.com/");
Button mulai = (Button) findViewById(R.id.BT_Mulai);
final EditText nama = (EditText) findViewById(R.id.ET_nama);
final EditText telp = (EditText) findViewById(R.id.ET_telp);
mulai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Map<String, String> post1 = new HashMap<String, String>();
post1.put("Nama", nama.getText().toString());
post1.put("Telp", telp.getText().toString());
ref.push().setValue(post1);
}
});
ref.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
dataku user = dataSnapshot.getValue(dataku.class);
System.out.println(user.getNama().toString());
}
});
}
}
https://datasiswa.firebaseio.com/ this is my firebase link (structure) how can i retrieve only "nama" every i add child by button ? hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe hehehehehehehe
Aucun commentaire:
Enregistrer un commentaire