Android Question [Solved] ACSpinner Add method crashing the app

Biswajit

Active Member
Licensed User
Hi,

I'm trying to add items to ACSpinner from Appcompat v4. But the Add method of the ACSpinner crashing the app. Here is the log,
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
android.view.InflateException: Binary XML file line #17 in com.forum.mall:layout/ac_spinner_row_layout: Binary XML file line #17 in com.forum.mall:layout/ac_spinner_row_layout: Error inflating class TextView
Caused by: android.view.InflateException: Binary XML file line #17 in com.forum.mall:layout/ac_spinner_row_layout: Error inflating class TextView
Caused by: java.lang.IllegalArgumentException: Font {path=null, style=FontStyle { weight=300, slant=0}, ttcIndex=0, axes=, localeList=, buffer=java.nio.DirectByteBuffer[pos=0 lim=242068 cap=242068]} has already been added
    at android.graphics.fonts.FontFamily$Builder.addFont(FontFamily.java:100)
    at androidx.core.graphics.TypefaceCompatApi29Impl.createFromFontFamilyFilesResourceEntry(TypefaceCompatApi29Impl.java:117)
    at androidx.core.graphics.TypefaceCompat.createFromResourcesFamilyXml(TypefaceCompat.java:120)
    at androidx.core.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:426)
    at androidx.core.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:372)
    at androidx.core.content.res.ResourcesCompat.getFont(ResourcesCompat.java:350)
    at androidx.appcompat.widget.TintTypedArray.getFont(TintTypedArray.java:119)
    at androidx.appcompat.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:430)
    at androidx.appcompat.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:140)
    at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:105)
    at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:95)
    at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:182)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
    at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
    at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1061)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
And here is the ac_spinner_row_layout content
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:aapt="http://schemas.android.com/aapt"
    android:orientation="horizontal"
    android:paddingTop="8dp"
    android:paddingBottom="8dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView android:gravity="center"
        android:layout_gravity="center_vertical"
        android:id="@+id/icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginLeft="16dp"/>

    <TextView android:textSize="16sp"
        android:gravity="center"
        android:id="@+id/text"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="16dp" android:minHeight="48dp"/>
</LinearLayout>
 
Last edited:

Biswajit

Active Member
Licensed User
Why do you need it? Add the regular spinner or better, B4XComboBox from XUI Views.
This is an old project. Not too old just a few months. Changing that to B4XCombobox will require extra works and changing internal codes. I just want to change a text for an update.
Building the layout with XML files is not the correct way to develop with B4A.
I'm adding the ACSpinner from the designer. This XML content is coming from AppCompat library itself. For clarification of the error log I posted the XML content.

It was working before updating the sdk from B4A sdk manager.
 

Biswajit

Active Member
Licensed User
I'm sure that changing to the standard Spinner won't be too complicated.
I've tried but the standard spinner does not support CSbuilder. As the whole app design is built with a custom font I have to show the font in the Spinner too. ACSpinner supports that but the standard spinner doesn't.
 

Biswajit

Active Member
Licensed User
There was nothing to do with the AppCompat library. There was a problem with the custom font file.
 
Top