Android Question How to get ImageView using GetView?

Jerryk

Active Member
Licensed User
Longtime User
In my custom view I load layouts. The first one contains a Panel and in it is a Label. Reading the Label is no problem.
B4X:
tilesPanel.LoadLayout("_pnlLabel")
Dim pnl As Panel
pnl = tilesPanel.GetView(0)
Dim lbl As Label = pnl.GetView(0)
lbl.Width = pnl.Width
lbl.Height = pnl.Height
lbl.Text = pText
The second one contains a Panel and in it an Imageview. Loading the ImageView is with an error
B4X:
tilesPanel.LoadLayout("_pnlImage")
Dim pnl As Panel
pnl = tilesPanel.GetView(0)
Dim img As ImageView = pnl.GetView(0)
img.Width = pnl.Width
img.Height = pnl.Height
img.Bitmap = LoadBitmap(File.DirAssets, pBitmap) - error

java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageView
 

Sagenut

Expert
Licensed User
Longtime User
It looks correct.
Can you share an example with the same layouts to check?
 
Upvote 0
Top