C# 找不到具有LinearLayout和MapView的id的视图
我得到一个错误,说明 java.lang.IllegalArgumentException:找不到id为0x7f0e00a7的视图 (com.jvlapps.myapp:id/linearLayout1)用于片段ParamMapFragment 以下是我的布局:C# 找不到具有LinearLayout和MapView的id的视图,c#,android,android-fragments,xamarin,C#,Android,Android Fragments,Xamarin,我得到一个错误,说明 java.lang.IllegalArgumentException:找不到id为0x7f0e00a7的视图 (com.jvlapps.myapp:id/linearLayout1)用于片段ParamMapFragment 以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/an
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linearLayout1">
<com.google.android.gms.ads.AdView
android:id="@+id/bannerAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@+string/AdMob_TEST_Unit_Id" />
<fragment
android:name="GetMeThere.MainMenuFragment"
android:id="@+id/MainMenuFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
以下是我的活动的OnCreate:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var agencyName = Intent.Extras.GetString("current_agency", "None");
var mapFrag = ParamMapFragment.NewInstance(agencyName);
FragmentManager.BeginTransaction()
.Add(Resource.Id.linearLayout1, mapFrag, "main_map_fragment")
.Commit();
}
我已经为此挣扎了好几个小时了。我甚至不知道我现在在做什么,也不知道我的应用程序还能做什么。我将完成此应用程序的制作,然后销毁整个宇宙。您需要调用
SetContentView(Resource.Layout.)添加片段之前,在活动的OnCreate
方法中执行code>。否则,您的活动没有任何内容视图,并且无法找到id/linearLayout1
的任何内容,您在哪一行收到此错误?@Mehmed VS说“所有线程都在执行外部代码”,所以我没有收到具体的行。但是FragmentManager.BeginTransaction().Add。。。这条线就是我一次穿过一条线的地方。
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var agencyName = Intent.Extras.GetString("current_agency", "None");
var mapFrag = ParamMapFragment.NewInstance(agencyName);
FragmentManager.BeginTransaction()
.Add(Resource.Id.linearLayout1, mapFrag, "main_map_fragment")
.Commit();
}