2017-05-20 20 views
0

私は、Googleマップと車の番号と1日を選択する2つのスピナーが必要な部分があります。私のスピナーがなぜ表示されないのか知っていますか?私はaxmlファイルを見ているときに表示されますが、私は自分の携帯電話でアプリケーションを実行すると、地図だけが表示されます。私は何が欠けていますか?これは、赤とdrawedされXamarin Android Spinnerが表示されない

<?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> 

を.axmlもされ

、スピナーが表示されるはずです。 enter image description here

これは私があなたの最初のTableRowで)

 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; 
     } 

答えて

3

私は.csで、spinnerCarで)などandroid:layout_height="50dp"

IIとして、固定サイズでRelativeLayoutの高さを設定、android:margin_leftを削除すると、無効でエラーが発生する可能性があります。

III)各スピンner(spinnerCarspinnerDate)は固定幅を設定します。たとえばandroid:layout_width="120dp"です。

+0

ありがとうございます。出来た –

関連する問題