小例子将描述这种情况:
flavorDimensions 'shape', 'api'
productFlavors {
fruit {
dimension "shape"
}
vegtable {
dimension "shape"
}
production {
dimension "api"
}
development {
dimension "api"
}
}
Run Code Online (Sandbox Code Playgroud)
任务: 我需要为fruitProduction和fruitDevelopment风格保留不同的签名配置。
我研究了 gradle 文档,但没有找到合适的任务,可以覆盖特殊风格的配置。
android android-productflavors android-build-flavors android-flavors apk-signing
模型的setter和getter方法具有一个参数,如下所示:
public int getPrice(Object key) {
}
public void setPrice(Object key, int price) {
}
Run Code Online (Sandbox Code Playgroud)
XML看起来像这样:
<EditText
android:id="@+id/edtPrice"
style="@style/CreateShipperItemValueEditTextView"
android:layout_centerVertical="true"
android:hint="@string/hint_price"
android:inputType="number"
android:maxLines="1"
android:text="@={shipper.getPrice(priceKey)}"/>
Run Code Online (Sandbox Code Playgroud)
android:text =“ @ = {shipper.getPrice(priceKey)}”
构建过程中的编译器错误表明我们应该使用@InverseMethod批注。我尝试这样的事情:
@InverseMethod(value = "getPrice")
@Override
public void setPrice(Object key, int price) {
super.setPrice(key, price);
}
Run Code Online (Sandbox Code Playgroud)
但是在这种情况下,我有下一个错误。
error: @InverseMethods must have a non-void return type
Run Code Online (Sandbox Code Playgroud)
因此,我很高兴在这里对整个流程进行很好的解释。谢谢