AppBase for Android rapid development -- (3). Details about IHolder, IData, and appbaseiholder
AppBase for Android rapid development -- (3). Detailed description of IHolder and IData
IHolder and IData are two components of AVLib. They have been used before, so this article will detail the usage of these two components.
IHolder
IHolder is a component specification automatically bound to View in AVLib. All @ IDS can only be used in classes derived from IHolder.
public class Holder extends IHolder{ @Id(R.id.tvTitle) TextView tvTitle; @Id(value = R.id.imgIcon, src = R.drawable.imgIcon) ImageView imgIcon; @Override public void initViewParams(){ }}
IData
IData is a component specification automatically bound to data in AVLib. All @ DataBind can only exist in classes derived from IData.
Package com. snicesoft. avlib. rule;/*** @ author zhu zhe * @ since 9:54:17 on January 1, April 15, 2015 * @ version V1.0 */public abstract class IData {}
IData only defines component specifications and must inherit IData.
2. @ DataBind
Id (): ResourceId value of the View
DataType (): The Bound data type, which can be string, img, adapter, or null. The default value is string.
LoadingResId (): If it is bound to an image, this is the buffer image to be loaded.
FailResId (): If the image is bound, this indicates that the image fails to be loaded.
Prefix (): prefix of the currently bound value
Suffix (): The suffix of the currently bound value
Pattern (): The current bound value. If time is required for formatting, the configuration can be completed.
Example
@ DataBind (id = R. id. tvTitle, prefix = "I Am a singer-") String title = "Season 2 ";
The final tvTitle value is "I am a singer-Season 2 ".
@DataBind(id = R.id.imgIcon,dataType = DataType.IMG, prefix = "http://img.xx.com/woshigeshou/")String icon = "upload/539728234.png";
In the final result, the online image http://img.xx.com/woshigeshou/upload/542528234.pngis sent to imgicon.
@DataBind(id = R.id.lvData, dataType = DataType.ADAPTER)ListDemoAdapter adapter = new ListDemoAdapter();
The final result will adapt this adapter to the lvData component.
3. Example
public class Data extends IData{ @DataBind(id = R.id.imgIcon,dataType = DataType.IMG, prefix = "http://img.xx.com/woshigeshou/") String icon = "upload/539728234.png"; @DataBind(id = R.id.lvData, dataType = DataType.ADAPTER) ListDemoAdapter adapter = new ListDemoAdapter();}
Key Points
Some people may ask why they still cannot see how to bind the rules and usage described above. All bindings are in the AVLib. java class, so I will not post code. You can check them by yourself.
From this structure, we can see initHolder and dataBind. Yes, the two are the methods for initializing Holder and binding data. SetLoadImg is used to configure the image loading function. Currently, BitmapUtils is used as the image loader in the appBase Application.
Last
Currently, IHolder and IData include common bindings, and there must be some content that cannot be bound. Please help us with the test and provide more suggestions or work with me to improve and optimize it. The following is a discussion group I created. welcome to join.
279307798