J Jerryk Active Member Licensed User Longtime User Jul 31, 2025 #1 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
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 Jul 31, 2025 #2 It looks correct. Can you share an example with the same layouts to check? Upvote 0
klaus Expert Licensed User Longtime User Aug 1, 2025 #4 It seems that you load more than one layout onto tilesPanel. Therfore, pnl = tilesPanel.GetView(0) gets always the first Panel. You should use pnl = tilesPanel.GetView(1) to get the second one. Upvote 0
It seems that you load more than one layout onto tilesPanel. Therfore, pnl = tilesPanel.GetView(0) gets always the first Panel. You should use pnl = tilesPanel.GetView(1) to get the second one.