What is the main purpose of setTag() getTag() methods of View?

前端 未结 7 617
醉话见心
醉话见心 2020-11-22 01:25

What is the main purpose of such methods as setTag() and getTag() of View type objects?

Am I right in thinking that I can ass

7条回答
  •  执念已碎
    2020-11-22 01:58

    We can use setTag() and getTag() to set and get custom objects as per our requirement. The setTag() method takes an argument of type Object, and getTag() returns an Object.

    For example,

    Person p = new Person();
    p.setName("Ramkailash");
    p.setId(2000001);
    button1.setTag(p);
    

提交回复
热议问题