我有1个自定义视图,扩展了ConstraintLayout并包含1个EditText和2个TextViews
在我的自定义视图中,我定义了此attr(和其他属性):
<attr name="Text" format="string" />
我像这样使用它:
app:Text="@={login.email}"
在我的自定义视图中,我定义了:
companion object {
@JvmStatic @BindingAdapter("Text")
fun setText(nMe : View, nText: String) {
nMe.nInput.setText(nText)
}
@InverseBindingAdapter(attribute = "Text")
fun getText(nMe : View) : String {
return nMe.nInput.text.toString()
}
女巫在单向绑定中效果很好
app:Text="@{login.email}"
但是当我尝试在双向绑定中使用它时,我得到了指向ActivityLoginBinding.java java.lang.String callbackArg_0 = mBindingComponent.null.getText(mEmail);
的错误提示。如何进行2向绑定?
L.E :经过一番研究,我最终得出以下结论:
@InverseBindingMethods(InverseBindingMethod(type =
CustomInput::class,attribute = "bind:Text",event =
"bind:textAttrChanged",method = "bind:getText"))
class CustomEditTextBinder {
companion object {
@JvmStatic
@BindingAdapter(value = ["textAttrChanged"])
fun setListener(editText: CustomInput, listener: InverseBindingListener?) {
if (listener != null) {
editText.nInput.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
}
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
}
override fun afterTextChanged(editable: Editable) {
listener.onChange()
}
})
}
}
@JvmStatic
@InverseBindingAdapter(attribute = "Text")
fun getText(nMe: CustomInput): String {
return nMe.nInput.text.toString()
}
@JvmStatic
@BindingAdapter("Text")
fun setText(editText: CustomInput, text: String?) {
text?.let {
if (it != editText.nInput.text.toString()) {
editText.nInput.setText(it)
}
}
}
}
}
但是现在我得到: 找不到事件TextAttrChanged
答案 0 :(得分:0)
我认为您只需要if (isset($_POST['button1'])) {
$input_data = $_POST['input1'];
// do other stuffs like foreach, if and etc..
// and return new data in array
$results = array();
echo json_encode($results);
}
。
这对我有用(如果文本为0,则将文本设置为空
Sub Convert_ExceltoPDF()
Application.DisplayStatusBar = True
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Dim n As Integer
Dim x As Integer
Dim wb As Workbook
Dim I As Long
Set sh = ThisWorkbook.Sheets("Sheet1")
Set fo = fso.GetFolder(sh.Range("E3").Value)
For Each f In fo.Files
n = n
Application.StatusBar = "Processing..." & n & "/" & fo.Files.Count
Set wb = Workbooks.Open(f.Path)
Call Print_Settings(f, xlPaperLetter)
wb.ExportAsFixedFormat xlTypePDF, sh.Range("E4").Value & Application.PathSeparator & VBA.Replace(f.Name, ".xlsx", ".pdf"), quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True
Call Print_Settings(f, xlPaperLetter)
wb.Close
Next
Application.StatusBar = ""
MsgBox "Process Complete"
End Sub
Sub Print_Settings(f As File, ePaperSize As XlPaperSize)
On Error Resume Next
Application.PrintCommunication = False
With PageSetup
LeftMargin = Application.InchesToPoints(0)
RightMargin = Application.InchesToPoints(0)
TopMargin = Application.InchesToPoints(0)
BottomMargin = Application.InchesToPoints(0)
HeaderMargin = Application.InchesToPoints(0)
FooterMargin = Application.InchesToPoints(0)
Orientation = xlLandscape
PaperSize = ePaperSize
Zoom = False
FitToPagesWide = 1
FitToPagesTall = 1
End With
Application.PrintCommunication = True
End Sub
):
event = "android:textAttrChanged"