简体   繁体   English

如何防止自定义视图在“ Mono for Android”的屏幕方向更改中丢失状态

[英]How to prevent Custom Views from losing state across screen orientation changes for “ Mono for Android”

this link shows "How to prevent Custom Views from losing state across screen orientation changes" for java. 该链接针对Java显示了“如何防止自定义视图在屏幕方向变化时丢失状态”。 My question is "How to prevent Custom Views from losing state across screen orientation changes" for Mono for Android. 我的问题是Android版Mono的“如何防止自定义视图在屏幕方向变化时丢失状态”。

And How transfer java code to c# code 以及如何将Java代码转换为C#代码

public static final Parcelable.Creator<SavedState> CREATOR =
    new Parcelable.Creator<SavedState>() {
      public SavedState createFromParcel(Parcel in) {
        return new SavedState(in);
      }
      public SavedState[] newArray(int size) {
        return new SavedState[size];
      }
};

I don't know if you want to do is possible or not but I do know that at this time a translation of the example java code is not possible because it is using Parcelable . 我不知道您是否想做,但我确实知道目前无法翻译示例Java代码,因为它使用的是Parcelable

Below is an excerpt from the mono for android limitations page which can be viewed here 以下是来自android限制页面的mono的摘录,可以在此处查看

Android.OS.IParcelable cannot be implemented. 无法实现Android.OS.IParcelable。

The IParcelable interface cannot be implemented at this time because the android.os.Parcelable interface requires: 目前无法实现IParcelable接口,因为android.os.Parcelable接口需要:

Classes implementing the Parcelable interface must also have a static field called CREATOR, which is an object implementing the Parcelable.Creator interface. 实现Parcelable接口的类还必须具有称为CREATOR的静态字段,该字段是实现Parcelable.Creator接口的对象。

Since mandroid.exe currently cannot generate fields, this interface cannot be implemented. 由于mandroid.exe当前无法生成字段,因此无法实现此接口。 Support will be added in a future release. 在将来的版本中将添加支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM