【发布时间】:2017-01-13 22:24:43
【问题描述】:
我能够显示自动完成建议中的所有项目,但是当我单击一个项目时,我希望将与该项目关联的经度和纬度坐标绘制在地图上。我目前不知道如何实现。 `请在这里帮忙。
我在下面粘贴了我的方法
private void searchAutocomplete(){
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
//Create a new ArrayAdapter with your context and the simple layout for the dropdown menu provided by Android
final ArrayAdapter<String> autoComplete = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1);
//Child the root before all the push() keys are found and add a ValueEventListener()
database.child("wr").child("clubs").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Basically, this says "For each DataSnapshot *Data* in dataSnapshot, do what's inside the method.
for (DataSnapshot suggestionSnapshot : dataSnapshot.getChildren()){
//Get the suggestion by childing the key of the string you want to get.
String suggestion = suggestionSnapshot.child("name1").getValue(String.class);
//Add the retrieved string to the list
autoComplete.add(suggestion);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
AutoCompleteTextView ACTV= (AutoCompleteTextView)findViewById(R.id.autocompleteView);
ACTV.setAdapter(autoComplete);
ACTV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
}
【问题讨论】:
标签: android google-maps firebase-realtime-database autocompletetextview