Android: How to put an Enum in a Bundle?

前端 未结 12 1419
别那么骄傲
别那么骄傲 2020-12-22 16:56

How do you add an Enum object to an Android Bundle?

12条回答
  •  北海茫月
    2020-12-22 17:17

    I think convert enum to int (for normal enum) and then set on bundle was been easiest way. like this code for intent:

    myIntent.PutExtra("Side", (int)PageType.Fornt);
    

    then for check state:

    int type = Intent.GetIntExtra("Side",-1);
    if(type == (int)PageType.Fornt)
    {
        //To Do
    }
    

    but not work for all enum type!

提交回复
热议问题