Ich habe ein Fragment, wo ich Google Karte und zwei Spinner haben, um eine Auto-Nummer und einen Tag zu wählen. Weißt du warum meine Spinner nicht zeigen? Wenn ich in axml Datei schaue, zeigen sie, aber wenn ich die App auf meinem Telefon starte, wird nur die Karte angezeigt. Was vermisse ich? DieseXamarin Android Spinner nicht angezeigt
ist .axml kann
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">
<TableRow>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txtRefreshData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Car number"
android:layout_marginLeft="40dp" />
<Spinner
android:id="@+id/spinnerCar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:margin_left="30dp"
android:layout_toRightOf="@id/txtRefreshData"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/txtspinnerDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Day"
android:layout_toRightOf="@id/spinnerCar"
android:layout_marginLeft="30dp" />
<Spinner
android:id="@+id/spinnerDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/txtspinnerDate"
android:layout_marginLeft="10dp" />
</RelativeLayout>
</TableRow>
<TableRow>
<LinearLayout
android:id="@+id/map_placeholder"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
Wo mit roten drawed ist, sollten die Spinnereien zeigen.
Das ist mein CS- ist
GoogleMap map;
MapFragment mapFragment;
List<LatLng> markers = new List<LatLng>();
List<string> carnumbers = new List<string>();
MarkerOptions markerOptions;
TextView txtRefreshData;
public void OnMapReady(GoogleMap googleMap)
{
int ct = 1;
if (markers.Count > 0)
{
foreach (var item in markers)
{
map = googleMap;
markerOptions = new MarkerOptions();
markerOptions.SetPosition(item);
markerOptions.SetTitle("My Position" + ct);
map.AddMarker(markerOptions);
ct++;
}
FitAllMarkers(map);
}
}
private void FitAllMarkers(GoogleMap googleMap)
{
LatLngBounds.Builder builder = new LatLngBounds.Builder();
foreach (LatLng item in markers)
{
builder.Include(item);
}
LatLngBounds bounds = builder.Build();
CameraUpdate cu = CameraUpdateFactory.NewLatLngBounds(bounds, 100);
googleMap.AnimateCamera(cu);
}
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
mapFragment = MapFragment.NewInstance();
var ft = Activity.FragmentManager.BeginTransaction();
ft.Add(Resource.Id.map_placeholder, mapFragment).Commit();
mapFragment.GetMapAsync(this);
}
public async override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.LiveTrackingAdminFragment, container, false);
this.Activity.Title = "Live Tracking";
Spinner spinner = view.FindViewById<Spinner>(Resource.Id.spinnerCar);
Spinner spinner = view.FindViewById<Spinner>(Resource.Id.spinnerDay);
return view;
}
Vielen Dank. Es funktionierte –