Android Question Cannot Set ASRatingBar Enabled property

rgarnett1955

Active Member
Licensed User
Longtime User
Hi

I wish to enable/disable a rating bar.

I tries using similar code to that which Iuused for a B4XComboBox, but I get an error:

Set Form Edit:
'======================================================================================================
public Sub setFormEnableEdit
    imgEditCrop.Visible = False
    imgUndoCrop.Visible = False
    imgSaveCrop.Visible  = False
    tfeComment.EditEnabled = True

    acSpinSeed.mBase.GetView(0).Enabled = True  '*** This works OK ***
    tfeComment.EditEnabled     = True
    
    pctHarvested.mBase.GetView(0).Enabled = False '*** Error: Cannot access private member mbase: ***
    
    datePlanted.Enabled = True
    dateHarv.Enabled = True
    dateCleared.Enabled = True
    cbFin.Enabled = True
End Sub

Am I doing something wrong?
What is the correct approach?

Best regards
Rob
 

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I fixed the problem by modifying the library ASRatingBar.b4xlib viz:

Make mBase Public:
Sub Class_Globals
    Private mEventName As String 'ignore
    Private mCallBack As Object 'ignore
'    Private mBase As B4XView 'ignore   *** remove ***
    Public mBase As B4XView 'ignore
    Private xui As XUI 'ignore
    
    Private xBackgroundView As B4XView
    Private xbmp_image ,xbmp_grey_image As B4XBitmap
    Private current_ranking As Int
    
    Private g_MaxRating As Int
End Sub

I created a new library called ASRatingBar_RJG.b4xlib, attached this to this post.

I seems to me that when people make custom views there should be a few rules:

Should have a standard set of properties available from the code:
  • Visibility
  • Enabled
  • Font properties: Size, Style, Color, Color Background, Standard Type faces
  • Text padding
  • Text alignment
  • Border width, color, radius etc

These properties are invariably available in the Designer, but when you want to use them in the code you have to waste hours figuring out how to do it. I spent an hour on the problem related in this post.

What do others think?

Best regards
Rob
 

Attachments

  • ASRatingBar_RJG.b4xlib
    2.1 KB · Views: 144
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Public mBase As B4XView 'ignore
Dont do this.
Make a sub for this...
V1.01
-Add getBase
-Add public variable Tag
Should have a standard set of properties available from the code:
always depends on the view.
These properties are invariably available in the Designer, but when you want to use them in the code you have to waste hours figuring out how to do it. I spent an hour on the problem related in this post.
don't waste time and ask questions ;)
 
Upvote 0
Top