Java 如何从firebase中的每个节点读取特定值?
我想在谷歌地图中显示一组自定义标记(来自com.google.maps.android:android-maps-utils:0.5的IconGenerator)。但是构建标记的数据,LatLong位置在firebase数据库中,每个子级都有自己的位置值,我如何读取每个子级的位置并将其传递给将显示标记的类 在儿童“购买”中,每个儿童都有自己的位置钥匙,租金和地段也一样 请提供帮助、概念解释和代码 同样,对于租金和地块,您可以通过以下方式传递-Java 如何从firebase中的每个节点读取特定值?,java,android,firebase-realtime-database,google-maps-markers,Java,Android,Firebase Realtime Database,Google Maps Markers,我想在谷歌地图中显示一组自定义标记(来自com.google.maps.android:android-maps-utils:0.5的IconGenerator)。但是构建标记的数据,LatLong位置在firebase数据库中,每个子级都有自己的位置值,我如何读取每个子级的位置并将其传递给将显示标记的类 在儿童“购买”中,每个儿童都有自己的位置钥匙,租金和地段也一样 请提供帮助、概念解释和代码 同样,对于租金和地块,您可以通过以下方式传递- DatabaseReference dbRent
DatabaseReference dbRent = FirebaseDatabase.getInstance().getReference("Rent");
DatabaseReference dbLot = FirebaseDatabase.getInstance().getReference("Lot");
我希望这会有帮助
同样,对于租金和地块,您可以通过以下方式传递-
DatabaseReference dbRent = FirebaseDatabase.getInstance().getReference("Rent");
DatabaseReference dbLot = FirebaseDatabase.getInstance().getReference("Lot");
我希望这会有帮助 你试过什么了吗?因为若并没有这一点,这对于一个关于堆栈溢出的问题来说太宽泛了,我建议从Firebase或开始。谢谢@Frank van Puffelen。威尔调查一下你试过什么了吗?因为若并没有这一点,这对于一个关于堆栈溢出的问题来说太宽泛了,我建议从Firebase或开始。谢谢@Frank van Puffelen。我会调查的谢谢你的快速回复Raj。但我想在“购买”的每个子项中读取“位置”字段。但是“Lot”和“Rent”的结构与“Buy”相同,我想阅读他们每个孩子的“location”字段。谢谢@Raj,我会调查一下,并随时通知你。非常感谢你的回复。我想做的是:制作一个房地产应用程序。当你点击一个标记时,它会显示一个带有相应房屋的碎片。我很想念这张大图,你可以通过那个纬度,经度,展示一座房子。刚刚上传了一张照片。这是一个带有cardview的回收视图。单击cardview时,会打开详细视图。“晶圆厂”按钮打开带有标记的地图。它将填满“购买”、“租赁”和“批次”选项卡中的所有标记。如何使用这些项目的位置并在mapActivity中显示它们,然后当您单击标记时,它将打开该项目的详细视图。感谢您的快速回复。但我想在“购买”的每个子项中读取“位置”字段。但是“Lot”和“Rent”的结构与“Buy”相同,我想阅读他们每个孩子的“location”字段。谢谢@Raj,我会调查一下,并随时通知你。非常感谢你的回复。我想做的是:制作一个房地产应用程序。当你点击一个标记时,它会显示一个带有相应房屋的碎片。我很想念这张大图,你可以通过那个纬度,经度,展示一座房子。刚刚上传了一张照片。这是一个带有cardview的回收视图。单击cardview时,会打开详细视图。“晶圆厂”按钮打开带有标记的地图。它将填满“购买”、“租赁”和“批次”选项卡中的所有标记。如何使用这些项目的位置并在mapActivity中显示它们,然后当您单击标记时,它将打开该项目的详细视图。
package com.realty.drake.kunuk;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.MenuItem;
import android.widget.Toast;
import java.text.NumberFormat;
import java.util.Locale;
public class PropertyDetail extends AppCompatActivity implements Toolbar.OnMenuItemClickListener {
@Override
protected void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.property_detail);
Toolbar myToolbar = (Toolbar) findViewById(R.id.kunuk_toolbar);
myToolbar.inflateMenu(R.menu.menu_detail);
setSupportActionBar(myToolbar);
myToolbar.setOnMenuItemClickListener(this);
//collect our intent
Intent intent = getIntent();
Property property = intent.getParcelableExtra("Property");
boolean isRent = getIntent().getBooleanExtra("isRent", false);
//collect all property values from Parcelable
int price = property.getPrice();
String address = property.getAddress();
int numberOfBed = property.getNumberOfBed();
int numberOfBath = property.getNumberOfBath();
int numberOfCar = property.getNumberOfCar();
String propertyImage = property.getPropertyImage();
float propertyDim = property.getPropertyDim();
String propertyDesc = property.getPropertyDesc();
// Get a support ActionBar corresponding to this toolbar
ActionBar ab = getSupportActionBar();
// Enable the Up button
ab.setDisplayHomeAsUpEnabled(true);
BottomNavigationView bottomNavigationView = (BottomNavigationView)
findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_call:
Uri callNumberUri = Uri.parse("tel:+50937438713");
Intent callIntent = new Intent(Intent.ACTION_DIAL, callNumberUri);
startActivity(callIntent);
break;
case R.id.action_sms:
Uri smsNumberUri = Uri.parse("sms:+50937438713");
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsNumberUri);
startActivity(smsIntent);
break;
case R.id.action_email:
//TODO get a property id to use in subject email field
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Kunuk Request");
emailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] {"drakecolinj@gmail.com"});
startActivity(emailIntent);
}
return false;
}
});
//Bind the data from the Parcelable to the Views
TextView addressDetail = findViewById(R.id.post_address);
addressDetail.setText(String.valueOf(address));
String currencyPrice = NumberFormat //Format the price variable in currency form
.getCurrencyInstance(Locale.US)
.format(price);
TextView priceDetail = findViewById(R.id.post_price);
priceDetail.setText(currencyPrice);
ImageView imageView = findViewById(R.id.post_propertyImage);
//take one long string containing multiple url and parse it
String propertyImageArray[] = propertyImage.split(",");
//TODO add loading icon for placeholder
// Download directly from StorageReference using Glide
// (See MyAppGlideModule for Loader registration)
GlideApp.with(getApplication())
.load(propertyImageArray[0])
.fitCenter()
.into(imageView);
TextView bathroomDetail = findViewById(R.id.post_bathroom);
bathroomDetail.setText(String.valueOf(numberOfBath));
TextView bedroomDetail = findViewById(R.id.post_bedroom);
bedroomDetail.setText(String.valueOf(numberOfBed));
TextView garageDetail = findViewById(R.id.post_garage);
garageDetail.setText(String.valueOf(numberOfCar));
TextView propertyDimDetail = findViewById(R.id.property_dim);
propertyDimDetail.setText(String.valueOf(propertyDim));
TextView propertyDescDetail = findViewById(R.id.property_desc);
propertyDescDetail.setText(String.valueOf(propertyDesc));
if (isRent) {
final TextView rentUnit = findViewById(R.id.rent_unit_detail);
rentUnit.setVisibility(View.VISIBLE);
}
}
@Override
public boolean onMenuItemClick(MenuItem item){
switch (item.getItemId()) {
case R.id.action_share:
Toast.makeText(this, "Shared", Toast.LENGTH_SHORT).show();
return true;
}
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_detail, menu);
return true;
}
}
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Buy");
databaseReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
// Let us retrieve value of location
Log.i("Price", dataSnapshot.child("location").getValue().toString());
// In this way you can retrieve all the fileds.
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
DatabaseReference dbRent = FirebaseDatabase.getInstance().getReference("Rent");
DatabaseReference dbLot = FirebaseDatabase.getInstance().getReference("Lot");