Ich möchte Google Place Picker in meiner App verwenden. Ich habe diesen Link https://developers.google.com/places/android-api/placepicker gefolgt und Ortswähler in meinem Fragment hinzugefügt, aber es nicht die Farbe oder das Thema meiner App erhalten. Die Symbolleiste der Ortsauswahl zeigt eine weiße Farbe.Wie kann ich die Google-Bereichsauswahl als das Thema meiner App sehen lassen?
Es ist in Dokument geschrieben, dass der Picker colorPrimary aus dem Material Thema der App nimmt. Ich habe auch eine colorPimary
und colorPrimaryDark
im meine style.xml
.
Was läuft hier falsch?
Code:
public class NameOfBusinessFragment extends Fragment {
int PLACE_PICKER_REQUEST = 1;
int RESULT_OK = -1;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
EditText category,location;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_name_of_business,
container, false);
location = (EditText)view.findViewById(R.id.location);
location.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
}
catch (GooglePlayServicesRepairableException e)
{
Toast.makeText(getActivity(),"ServiceRepaire Exception",Toast.LENGTH_SHORT).show();
}
catch (GooglePlayServicesNotAvailableException e)
{
Toast.makeText(getActivity(),"SeerviceNotAvailable Exception",Toast.LENGTH_SHORT).show();
}
}
});
return view;
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(data, getActivity());
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(getActivity(), toastMsg, Toast.LENGTH_LONG).show();
location.setText(place.getName());
}
}
}
}
Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBarOverlay">false</item>
<item name="windowActionBar">false</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:editTextStyle">@style/EditTextStyle</item>
</style>
<style name="EditTextStyle" parent="Widget.AppCompat.EditText">
<item name="colorControlNormal">@color/colorAccent</item>
<item name="colorControlActivated">@color/colorAccent</item>
<item name="colorControlHighlight">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Wie dies umgehen?
Sie haben eine Lösung für dieses Problem? Offenbar habe ich auch am 4.2.2. Geräte. Es scheint auf 5.1.1-Geräten gut zu funktionieren. –