-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] CodeBehind fragment & widget access (#1378
) Fragment handling code partially taken from: #1302 Fragments are treated as normal widget, with the difference that they have to be found using `FragmentManager.FindFragmentById()` instead of the usual `Activity.FindViewById()` method. Each generated class also gets a property named `Widget` which returns the actual Android widget as found in the layout file. This allows us to keep hierarchical nature of the XML code (thus handling nested widgets with duplicate ids gracefully) while being able to access the parent widget itself. The commit introduces a new attribute called `tools:managedType` which is used to specify the element associated property's type. We cannot use `tools:class` for this purpose since the layout root element already uses it to specify the name of the generated code-behind class and if the element had `android:id` on it, we would end up using the activity's type for the root element's property in the generated code, instead of its actual type.
- Loading branch information
Showing
6 changed files
with
456 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<fragment | ||
android:name="Xamarin.Android.RuntimeTests.MyFragment" | ||
android:id="@+id/csharp_simple_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
<fragment | ||
android:name="xamarin.android.runtimetests.MyFragment" | ||
android:id="@+id/csharp_legacy_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
<fragment | ||
android:name="Xamarin.Android.RuntimeTests.MyFragment, Mono.Android-Tests" | ||
android:id="@+id/csharp_partial_assembly" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
<fragment | ||
android:name="Xamarin.Android.RuntimeTests.MyFragment, Mono.Android-Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" | ||
android:id="@+id/csharp_full_assembly" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
/> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.