0
私のDialogFragmentの中に(Googleマップを保持する)フラグメントを追加する際に問題があります。私DialogFragmentの内部私はでframeLayoutこのDialogFragment内のフラグメントc#android
<FrameLayout
android:id="@+id/fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.google.android.gms.maps.MapFragment"/>
DialogFragmentを設定して、マップを追加しているしようとしているC#のコードのように設定しています。また、クラスでIOnMapReadyCallbackを指定しました。
using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
using Android.Graphics;
using Android.Gms.Maps;
using System;
using Android.Gms.Maps.Model;
namespace My_Town_App.Droid
{
class dialog_preview_busn : DialogFragment
{
public string gName, gAddress, gNumber, gEmail, gWebsite, gHours, gImage;
public int gZip;
private GoogleMap gMap;
public dialog_preview_busn(string Name, string Address, int Zip, string Number, string Email, string Website, string Hours, string Image)
{
gName = Name;
gAddress = Address;
gZip = Zip;
gNumber = Number;
gEmail = Email;
gWebsite = Website;
gHours = Hours;
gImage = Image;
System.Diagnostics.Debug.Write("-----------------");
System.Diagnostics.Debug.Write("dialog_preview_busn");
System.Diagnostics.Debug.Write("-----------------");
System.Diagnostics.Debug.Write("Name: " + Name + " Address: " + Address + " Zip: " + Zip + " Number: " + Number);
System.Diagnostics.Debug.Write("Email: " + Email + " Website: " + Website + " Hours: " + Hours + " Image: " + Image);
//gOnLogInComplete.Invoke(this, new OnLogInEventArgs(gtxtEmail.Text, gtxtPassword.Text));
//PassedParams.Invoke(this, new PassedParams(user, pass));
}
//----------------------------------------
// OnCreate Activity
//----------------------------------------
public override void OnActivityCreated(Bundle savedInstanceState)
{
Dialog.Window.RequestFeature(WindowFeatures.NoTitle); //Set the Title Bar to invisable
base.OnActivityCreated(savedInstanceState);
TextView txtName = View.FindViewById<TextView>(Resource.Id.txtName);
TextView txtAdress = View.FindViewById<TextView>(Resource.Id.txtAddress);
TextView txtNumber = View.FindViewById<TextView>(Resource.Id.txtNumber);
TextView txtEmail = View.FindViewById<TextView>(Resource.Id.txtEmail);
TextView txtWebsite = View.FindViewById<TextView>(Resource.Id.txtWebsite);
TextView txtHours = View.FindViewById<TextView>(Resource.Id.txtHours);
TextView labHours = View.FindViewById<TextView>(Resource.Id.labHours);
ImageView downArrow = View.FindViewById<ImageView>(Resource.Id.downArrow);
LinearLayout mapLayout = View.FindViewById<LinearLayout>(Resource.Id.mapLayout);
mapLayout.Visibility = ViewStates.Gone;
SetUpMap();
downArrow.Click += delegate
{
System.Diagnostics.Debug.Write("down arrow is working");
if (mapLayout.Visibility == ViewStates.Visible)
{
downArrow.SetImageResource(Resource.Drawable.menu_down_arrow);
mapLayout.Visibility = ViewStates.Gone;
}
else if (mapLayout.Visibility == ViewStates.Gone)
{
downArrow.SetImageResource(Resource.Drawable.menu_up_arrow);
mapLayout.Visibility = ViewStates.Visible;
}
};
txtName.Text = gName;
txtName.PaintFlags = PaintFlags.UnderlineText;
txtAdress.Text = (gAddress + " " + gZip).ToString();
txtNumber.Text = gNumber;
txtEmail.Text = gEmail;
txtWebsite.Text = gWebsite;
string[] aryHours = gHours.Split(',');
foreach (string s in aryHours)
{
txtHours.Text += (s + " ").ToString();
}
labHours.PaintFlags = PaintFlags.UnderlineText;
Dialog.Window.Attributes.WindowAnimations = Resource.Style.dialog_animation; //set the animation
}
//----------------------------------------
// OnCreate View
//----------------------------------------
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
var view = inflater.Inflate(Resource.Layout.dialog_preview_busn, container, false);
return view;
}
private void SetUpMap()
{
if (gMap == null)
{
FragmentManager.FindFragmentById<MapFragment>(Resource.Id.fragment);
}
LatLng location = new LatLng(50.897778, 3.013333);
CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
builder.Target(location);
builder.Zoom(18);
builder.Bearing(155);
builder.Tilt(65);
CameraPosition cameraPosition = builder.Build();
CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);
MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById<MapFragment>(Resource.Id.fragment);
GoogleMap map = mapFrag.Map;
if (map != null)
{
map.MoveCamera(cameraUpdate);
}
}
public void OnMapReady(GoogleMap googleMap)
{
gMap = googleMap;
}
}
}
これについてのお手伝いをさせていただきます。
私が使用しようとしている私の完全な断片ファイルは、ここで助けてくれてありがとうございます。また、dialogFragmentを表示しているイベントは、リストビュー項目のitemlongclickにあります –