MonoDroid: Error when calling constructor of custom view – TwoDScrollView

Congratulations! You’ve hit a leaky abstraction. :-/ The problem is this: for better or worse, virtual method calls from constructors invoke the most derived method implementation. C# is the same as Java in this respect; consider the following program: using System; class Base { public Base () { Console.WriteLine (“Base..ctor”); M (); } public virtual … Read more

Xamarin Android – How to rebuild Resource.designer.cs

As recently as Xamarin Studio 5.6 (build 273) with Xamarin.Android 4.18.0, if you have manually deleted the Resource.designer.cs file from the project, rebuilding will regenerate Resource.designer.cs, but will not add it back into the project. So after attempting to rebuild once, the file will be present in the file system, but not in the project. … Read more

How can I programmatically include layout in Android?

Use a ViewStub instead of include: <ViewStub android:id=”@+id/layout_stub” android:inflatedId=”@+id/message_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”0.75″ /> Then in code, get a reference to the stub, set its layout resource, and inflate it: ViewStub stub = (ViewStub) findViewById(R.id.layout_stub); stub.setLayoutResource(R.layout.whatever_layout_you_want); View inflated = stub.inflate();

Custom Layout for DialogFragment OnCreateView vs. OnCreateDialog

I had the same exception with the following code: public class SelectWeekDayFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(“Are you sure?”).setPositiveButton(“Ok”, null) .setNegativeButton(“No way”, null).create(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.week_day_dialog, container, false); return view; } } You must choose … Read more

PushAsync is not supported globally on Android, please use a NavigationPage – Xamarin.Forms

You are calling “PushAsync”: public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } private void btnCourseList_Clicked(object sender, EventArgs e) { Navigation.PushAsync(new PageB()); } } but you did not start the NavigationPage, which normally is done in the App.cs class, or at least it should be started before any call to “PushAsync”: MainPage … Read more