Passing enum or object through an intent (the best solution)

前端 未结 15 928
时光取名叫无心
时光取名叫无心 2020-12-04 05:41

I have an activity that when started needs access to two different ArrayLists. Both Lists are different Objects I have created myself.

Basically I need a way to pa

15条回答
  •  自闭症患者
    2020-12-04 06:21

    You can pass an enum through as a string.

    public enum CountType {
        ONE,
        TWO,
        THREE
    }
    
    private CountType count;
    count = ONE;
    
    String countString = count.name();
    
    CountType countToo = CountType.valueOf(countString);
    

    Given strings are supported you should be able to pass the value of the enum around with no problem.

提交回复
热议问题