本文介绍了Android - 向ImageView添加多个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android编程的新手,想要创建一个应用程序,我可以在其中为显示的Image添加多个自定义标签。我研究了一下,发现了ImageView的 setTag()方法。但它确实提到它是否允许多个标记。
还有什么办法让这些标签在图像上保持可见(以及适当的标记位置)?

I am new at android programming and want to create an application in which I can add multiple custom tags to an displayed Image. I researched a bit and found out aboutsetTag() method of ImageView. But it does mention if it allows multiple tagging.Also is there any way that those tags to remain visible (along with appropriate tagged position) on the image?

我是否需要SurfaceView或GridView ?

Will I require an SurfaceView or GridView for this?

来源:

谢谢。

推荐答案

您可以使用MyTag类将以下多个数据标记为视图

Instead of looking for multiple tags you can use a class MyTag as follows to tag more than one data to a view

public class MyTag
{
   int  int_Tag;
   String  string_Tag;
   MyClass  myclass_obj_Tag;


    public MyTag()
    {
      int_Tag=0;
      string_Tag=null;
      myclass_obj_Tag=null;
    }

    public MyTag(int i,String s,MyClass m)
    {
      int_Tag=i;
      string_Tag=s;
      myclass_obj_Tag=m;
    }


}

创建一个对象此类的值并为对象中的变量赋值

create an object of this class and assign values to variables in object

MyTag myTag=new MyTag(1,"string_tag",myClass_obj);
iv.setTag(myTag);

试一试,我用过这个方法,

just give it a try,I have used this method,

这篇关于Android - 向ImageView添加多个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 16:25