문제

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?

Will I require an SurfaceView or GridView for this?

Sources :

Android Image View

android-Image View set Tag

Thank you.

도움이 되었습니까?

해결책

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,

다른 팁

You can add any object as a tag. If the data you're adding need more data, the simplest way would be to add a Hashtable as the tag. Then add all the key/value pairs you want to that Hashtable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top