android - How to get attributeset value as "@color/desktop_purple" -


i have 2 apks, such packagea, packageb; meanwhile create custom-view named homesuite here xml layout:

<linearlayout     style="@style/page_linearlayout"     android:layout_margintop="@dimen/hometopfragment_layout_margintop"     android:layout_weight="16" >      <com.my.example.view.homesuite         android:background="@color/desktop_purple"         android:layout_marginright="2dp"         android:layout_weight="1" />      <com.my.example.view.homesuite         android:background="@color/desktop_grey"         android:layout_marginright="2dp"         android:layout_weight="1" />      <com.my.example.view.homesuite         android:background="@color/desktop_light_green"         android:layout_weight="1" />  </linearlayout> 

here constructor:

public homesuite(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle);     int n = attrs.getattributecount();     string name ;     string value ;     for(int i=0;i<n;i++)     {         name = attrs.getattributename(i);         value = attrs.getattributevalue(i);     }     mcontext = (activity) context;     mpackagemanager = mcontext.getpackagemanager();  } 

when name="background", , value="@2131230733", i'm expecting "@color/desktop_purple", i'd use value resource name reading resource packageb.

    int id = packagebcontext.getresources().getidentifier(value, "color", packageb);     return packagebcontext.getresources().getcolor(id); 

i need know the value "@color/desktop_purple", can figure out it's "color" related or "drawable" related, after can decide use getcolor(id) or getdrawable(id).

anyone can help?


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -