Android Question [Solved] how to make Options value to take full width of preference dialog ?

AnandGupta

Expert
Licensed User
Longtime User
The value of "Options" is show on the right within a little space, see image, (the value is "Anand Gupta")
Untitled 2.jpg

how to make it to take full width of preference dialog ?
 
Solution
Here the code to the Options3 button:

B4X:
Private Sub btnOptions3_Click
    Dim sf As Object = prefdialog.ShowDialog(Options3, "OK", "CANCEL")
        
    For i = 0 To prefdialog.PrefItems.Size - 1
        Dim pi As B4XPrefItem = prefdialog.PrefItems.Get(i)
        
        If pi.ItemType = prefdialog.TYPE_OPTIONS Then
            Dim lbl As B4XView = prefdialog.CustomListView1.GetPanel(i).GetView(1)
            lbl.SetLayoutAnimated(0, lbl.Parent.Width - 65%x, lbl.Top, 200dip, lbl.Height)
        End If
    Next
    
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        PrintOptions(Options3, TextArea3)
    End If
End Sub
1693703802855.png

asales

Expert
Licensed User
Longtime User
Try this:
B4X:
If pi.ItemType = prefdialog.TYPE_SHORTOPTIONS Then
    Dim Parent As B4XView = prefdialog.CustomListView1.GetPanel(i).GetView(1)
    Parent.Left = (Parent.Left + Parent.Width) - 250dip
    Parent.Width = 250dip
    Dim view As B4XView = Parent.GetView( 0)
    view.Width = Parent.Width
End If
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Try this:
B4X:
If pi.ItemType = prefdialog.TYPE_SHORTOPTIONS Then
    Dim Parent As B4XView = prefdialog.CustomListView1.GetPanel(i).GetView(1)
    Parent.Left = (Parent.Left + Parent.Width) - 250dip
    Parent.Width = 250dip
    Dim view As B4XView = Parent.GetView( 0)
    view.Width = Parent.Width
End If
Thanks, but I need it for OPTIONS

I did changed it , but gives error
B4X:
        If pi.ItemType = pref.TYPE_OPTIONS Then
            Dim Parent As B4XView = pref.CustomListView1.GetPanel(i).GetView(1)
            Parent.Left = (Parent.Left + Parent.Width) - 250dip
            Parent.Width = 250dip
            Dim view As B4XView = Parent.GetView( 0)
            view.Width = Parent.Width
        End If

B4X:
Error occurred on line: 183 (BlankPage)
java.lang.RuntimeException: Type does not match (class android.widget.TextView)
    at anywheresoftware.b4a.objects.B4XViewWrapper.typeDoesNotMatch(B4XViewWrapper.java:405)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asPanelWrapper(B4XViewWrapper.java:111)
    at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:335)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
    at b4a.example.preferencesdialog._raisebeforedialogdisplayed(preferencesdialog.java:3119)
....

this is line 183
B4X:
Dim view As B4XView = Parent.GetView( 0)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Mr. Gupta: I have a thought on this, but since I am not sure of the question, I like to see a small project demonstrating it, unless of course someone else knows what you want and volunteers their answer.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Mr. Gupta: I have a thought on this, but since I am not sure of the question, I like to see a small project demonstrating it, unless of course someone else knows what you want and volunteers their answer.
Thanks, will make a small project.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi @Mahares I have taken below sample, project attached

When selecting "Options" from list with longer text, it shows truncated text as below,
WhatsApp Image 2023-09-02 at 5.31.44 PM (1).jpeg WhatsApp Image 2023-09-02 at 5.31.44 PM.jpeg WhatsApp Image 2023-09-02 at 5.31.45 PM.jpeg

See, "Albuquerque, NM" or "Colorado Springs, CO" shows truncated.
How to increase the text area full width so that they are not truncated ?
 

Attachments

  • Project.zip
    195 KB · Views: 44
Upvote 0

asales

Expert
Licensed User
Longtime User
Here the code to the Options3 button:

B4X:
Private Sub btnOptions3_Click
    Dim sf As Object = prefdialog.ShowDialog(Options3, "OK", "CANCEL")
        
    For i = 0 To prefdialog.PrefItems.Size - 1
        Dim pi As B4XPrefItem = prefdialog.PrefItems.Get(i)
        
        If pi.ItemType = prefdialog.TYPE_OPTIONS Then
            Dim lbl As B4XView = prefdialog.CustomListView1.GetPanel(i).GetView(1)
            lbl.SetLayoutAnimated(0, lbl.Parent.Width - 65%x, lbl.Top, 200dip, lbl.Height)
        End If
    Next
    
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        PrintOptions(Options3, TextArea3)
    End If
End Sub
1693703802855.png
 
Upvote 0
Solution
Top