Type cast from Java.Lang.Object to native CLR type in MonoDroid

前端 未结 8 1165
花落未央
花落未央 2021-02-02 13:38

How to cast Java.Lang.Object to some native type?

Example:

ListView adapter contains instances of native type Message. When i am trying to get SelectedItem from

8条回答
  •  长情又很酷
    2021-02-02 14:04

    it's work for me:

    public class HolderHelper : Java.Lang.Object {
        public readonly T Value;
    
        public HolderHelper (T value)
        {
            this.Value = value;
        }
    }
    

    test:

    chkFileName.Tag = new HolderHelper (item);
    LinkInfo link= (chkFileName.Tag as HolderHelper).Value;
    

提交回复
热议问题