Help with a custom View attributes inside a Android Library Project

后端 未结 6 1010
眼角桃花
眼角桃花 2020-11-30 21:55

I have a custom PieTimer View in an Android Library Project

package com.mysite.android.library.pietimer;

public class PieTimerView extends View {
...
         


        
6条回答
  •  旧巷少年郎
    2020-11-30 22:32

    For all APIs this is the receipt ( if the library is linked as JAR , but should work also as android library project reference)

    Library project: AndroidManifest.xml

    
    

    Library project: Attrs.xml

     
        
    
            
        ..  
    
    

    App project MainLayout.xml (or the layout where u use the custom control)

    
    
    
    
    

    In App Code if you want to access resources from library use (ex. array "MyCustomArray" defined in the arrays.xml fromthe lib) use:

    getResources().getStringArray(com.myapp.library1.R.array.MyCustomArray)
    

提交回复
热议问题