B4A Library XmlLayoutBuilder - Load Xml layouts

shashkiranr

Active Member
Licensed User
Longtime User
Hi All,

I am not able to capture the event of seekbar loaded using the xmllayout builder. Here the below xml.
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:padding="0dp"
    android:tag="original"
    android:gravity="center_vertical">
                 
    <SeekBar
        android:id="@+id/temposeek"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:progressDrawable="@drawable/custom_progress"
        android:maxHeight="3dp"
        android:minHeight="3dp"
        android:splitTrack="false"
        android:tag="TempoSeek"
        >     
    </SeekBar>
         
</LinearLayout>

I am having the sub to capture the seekchange event
B4X:
Sub TempoSeek_ValueChanged (Value As Int, UserChanged As Boolean)
    Log("change")
 
End Sub

Is there something I have missed. Is there any alternative way I can set the listener to the loaded seekbar. Kindly let me know.

Best,
SK

Edit: I found out a way.

Used the below code to set a listener on the seekbar
B4X:
Dim e As JavaObject = jo.CreateEvent("android.widget.SeekBar.OnSeekBarChangeListener","temposeek",False)
    jo.RunMethod("setOnSeekBarChangeListener",Array As Object(e))

Sub temposeek_Event (MethodName As String, Args() As Object) As Object
  
End Sub
 
Last edited:

moster67

Expert
Licensed User
Longtime User
I was trying to load an xml-file using the new ConstraintLayout but I got an error while the R.file was generated:

B4X:
B4A version: 6.30
Parsing code.    (0.00s)
Compiling code.    (0.07s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Generating R file.    Error
res\layout\layxml.xml:10: error: No resource identifier found for attribute 'layout_constraintTop_toTopOf' in package 'b4a.example'
res\layout\layxml.xml:10: error: No resource identifier found for attribute 'layout_constraintBottom_toBottomOf' in package 'b4a.example'
res\layout\layxml.xml:10: error: No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'b4a.example'
res\layout\layxml.xml:10: error: No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'b4a.example'

This is the xml-file:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mikael.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="16dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="16dp"
        android:id="@+id/txtbox1" />
</android.support.constraint.ConstraintLayout>

I noted that my project in Android Studio was using two dependencies:
-appcompat-v7
-constraint-layout
as can be shown here:

B4X:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
}

I tried to add the following two attributes in my B4A-project:

B4X:
#AdditionalJar: com.android.support:appcompat-v7
#AdditionalJar: constraint-layout

but it did not work.

Am I doing something wrong or is is simply B4A and the XMLLayoutBuilder library which cannot handle this new layout?
 

tuhatinhvn

Active Member
Licensed User
Longtime User
Updated 2021, XmlLayoutBuilder is not updated for AppCompat activity. If i use without Appcompat when i use tag "Panel" on Xml, app works well.
But when i use with appCompat error will display is Didn't find class android.View.Panel

Can you check and update for it?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…