I took value from Firebase
database and showed it on Textview
. I want to show that value in another Textview
on same activity. How to Pass it?
Here is my code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.show_units);
Intent intent = getIntent();
databaseBills = FirebaseDatabase.getInstance().getReference("bills");
Query lastQuery = databaseBills.orderByKey().limitToLast(1);
lastQuery.addListenerForSingleValueEvent(new ValueEventListener() {
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot childSnapshot: dataSnapshot.getChildren()) {
String value = childSnapshot.child("current_units").getValue(String.class);
Log.d("onDataChange", "current_units="+value);
pre_units.setText(value);
Double convert = Double.parseDouble(pre_units.getText().toString());
Intent intent = new Intent(getApplicationContext(), ShowUnits.class);
intent.putExtra("PreValue", convert);
} }
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
textViewCheck = (TextView) findViewById(R.id.textViewCheck);
cur_units = (TextView) findViewById(R.id.cur_units);
pre_units = (TextView) findViewById(R.id.pre_units);
textView17 = (TextView) findViewById(R.id.textView17);
Intent i = getIntent();
final double con = i.getDoubleExtra("Value", 0.0);
final double pre = i.getDoubleExtra("PreValue", 0.0);
cur_units.setText("" + con);
textViewCheck.setText("" +pre);