HELP List view resests normally this subtopic should be 6.html



1 Like

Isn’t there anyone?

hey whats ur problem. just say :slight_smile:

I click on the elements in ListView1 to move to an element in the second ListView, and from there I send a URL to the WebViewer based on the index, but the ListViewer resets the index.

Ok i will see this. :smiley:

show your blocks

test.aia (534.4 KB)

1 Like

What do u mean by index reset?:face_with_monocle:
First save the get start value in var. . then use it

When I make a selection in ListView2, the same URL always opens in the WebViewer."

In the listview2 picked u should set the list index of listview1.selection index.u set both of listview2 selection and selection index

I have HTML files hosted on my server, which I load using WebViewer. In cases where there is a server-related issue and the HTML file cannot be loaded, I want to prevent the URL of my website from being displayed. How can I achieve this? I’ve attached an image showing an example of the HTML file failing to load.

Try a Screen.ErrorOccurred event
Taufun

:white_check_mark: Steps to Prevent URL Display on Load Failure

1. Use a Splash Screen or Loader First

  • Before loading the WebViewer, show a loading screen or a spinner.
  • Only make the WebViewer visible if the content loads successfully.

2. Check If URL Can Be Loaded

  • Use the “Web” component in Kodular to make a quick HEAD request (or GET) to check if the HTML file is available before passing the URL to the WebViewer.

Blocks:

[Web.Url] ← "https://yourdomain.com/yourfile.html"
[Web.Get]

Then use the Web.GotText or Web.GotResponseCode to check status:

When Web.GotText
   if Web.ResponseCode = 200 then
       set WebViewer.Url to "https://yourdomain.com/yourfile.html"
       set WebViewer.Visible to true
   else
       show error message or fallback page

3. Use Local HTML File as Fallback

If the online HTML can’t be loaded, show a local HTML file (e.g., from assets) like this:

set WebViewer.Url to "file:///android_asset/error.html"

4. Handle WebViewer Errors Gracefully

Use WebViewer.ErrorOccurred block:

When WebViewer.ErrorOccurred
   set WebViewer.Visible to false
   show notifier with custom error

If helpful mark as solution

If there is no connection, the WebViewer doesn’t open — I’ve managed to fix that, thank you. In your solution, only a single URL is being checked. I have 30 URL addresses; should I turn them into a list and check them that way?

then use network block from kodular…
during screen init, use one if then else logic as

if is network connected
then // use blocks for true
else // use blocks for false

Yes, exactly! If you have 30 URLs, the best approach is to:

:white_check_mark: Store All URLs in a List and Check Them Sequentially

You can use a list of URLs, and then check them one-by-one using a loop with the Web component. Here’s a simplified flow:


Kodular Logic (Overview)

  1. Create a List of URLs
[Global urlList] = ["https://example.com/page1.html", ..., "https://example.com/page30.html"]
  1. Use an Index Variable
    Keep track of the current index you’re checking:
[Global urlIndex] = 1
  1. Check URLs Sequentially
Procedure CheckNextURL:
   if urlIndex ≤ length of urlList then
       set Web.Url to select item from list urlList at index urlIndex
       call Web.Get
   else
       show error: "No working URLs found"
  1. Handle Web.GotText or ResponseCode
When Web.GotText:
   if Web.ResponseCode = 200 then
       set WebViewer.Url to select item from urlList at urlIndex
       set WebViewer.Visible to true
   else
       increment urlIndex by 1
       call CheckNextURL
  1. Start the Check on Screen Initialize or Button Click
When Screen1.Initialize:
   call CheckNextURL

thanks to contribute with kodular