B4J Code Snippet Disable TextItem in B4XPreferencesDialog

Sometimes we want to lock a TextItem from being editable. For example a primary key item.
B4X:
Dim sf As Object = PrefDialog.ShowDialog(Data, "OK", "CANCEL")
If RowId > 0 Then
    Dim pi As B4XPrefItem = PrefDialog.GetPrefItem("Item Code") ' <-- Disallow edit on Item Code
    PrefDialog.CustomListView1.AnimationDuration = 0
    If pi.ItemType = PrefDialog.TYPE_TEXT Then
        Dim pnl As B4XView = PrefDialog.CustomListView1.GetPanel(0)
        Dim ft As B4XFloatTextField = pnl.GetView(0).Tag
        ft.mBase.Enabled = False
    End If
End If

Wait For (sf) Complete (Result As Int)
References:
 

pliroforikos

Active Member
Licensed User
hi
i tried to do the same with Password field without success. Any idea please?

B4X:
    Dim sf As Object = prefDialog.ShowDialog(mData, "OK", "CANCEL")
'    If RowId > 0 Then
        Dim pi As B4XPrefItem = prefDialog.GetPrefItem("Password1") ' <-- Disallow edit on Item Code
        prefDialog.CustomListView1.AnimationDuration = 0
        If pi.ItemType = prefDialog.TYPE_PASSWORD Then
            Dim pnl As B4XView = prefDialog.CustomListView1.GetPanel(0)
            Dim ft As B4XFloatTextField = pnl.GetView(0).Tag
            ft.mBase.Enabled = False
        End If
'    End If

The error is the bellow


This is my json file
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…