Android Tutorial Material Design 2 - Using the AppCompat library

Discussion in 'Tutorials & Examples' started by corwin42, Dec 19, 2014.

  1. corwin42

    corwin42 Expert Licensed User

    Are you using the standard B4A UI elements or the AppCompat CustomViews?
    The standard views will show black, the CustomViews should be fine.
     
  2. JohnCody

    JohnCody Well-Known Member Licensed User

    Corwin42, I am able to run your sample on this page:

    https://www.b4x.com/android/forum/t...compatible-with-older-android-versions.48423/

    But when I try to run the "AppCompatExample2" example on the first page of this thread I run into trouble:

    During Compile:
    ERROR: resource directory 'c:\users\stm\dropbox\basic4android\customlibsres\b4a_appcompat' does not exist

    I am assuming this should point to the directory where I put all new .JAR and .XML library files, so I changed the path to:
    #AdditionalRes: D:\Android\Basic4android\AddLibs\b4a_appcompat, de.amberhome.objects.appcompat

    But I then get error:
    ERROR: resource directory 'd:\android\basic4android\addlibs\b4a_appcompat' does not exist

    I don't have a "b4a_appcompat" directory - so I am assuming this is something that your 2.0 library needed, so I remmed it out.

    Then get a bunch of these errors during compile:

    \attrs.xml:546: error: Attribute "textAppearanceSearchResultTitle" has already been defined
    d:\android\android-sdk\extras\android\support\v7\appcompat\res\values\attrs.xml:548: error: Attribute "textAppearanceSearchResultSubtitle" has already been defined
    ....
    ....

    So I remmed out the below line because I assume it duplicates resources that are already in/used by your 3.2 version of the library:
    '#AdditionalRes: D:\Android\android-sdk\extras\android\support\v7\appcompat\res, android.support.v7.appcompat

    It then compiles and copies to device, but when it runs I get this error:

    ** Activity (main) Create, isFirst = true **
    main_activity_create (java line: 333)
    java.lang.RuntimeException: java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at de.amberhome.appcompat.example2.main._activity_create(main.java:333)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at de.amberhome.appcompat.example2.main.afterFirstLayout(main.java:102)
    at de.amberhome.appcompat.example2.main.access$000(main.java:17)
    at de.amberhome.appcompat.example2.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5293)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.NullPointerException
    at de.amberhome.objects.appcompat.ACEditTextWrapper.DesignerCreateView(ACEditTextWrapper.java:70)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 18 more
    java.lang.RuntimeException: java.lang.NullPointerException

    Any ideas how to fix?
     
  3. JohnCody

    JohnCody Well-Known Member Licensed User

    Also, I have a Android 4.2.2 device. So, the checkbox and radio circle showed up in dark black as you described.

    So, I replaced them with the ACCheckbox and ACRadioButton and they look good now. However, when the app starts, there is the sliding from top left corner animation of the entire activity. But it seems that the ACCheckBox and ACRadioButton controls *immediately* appear in their final position before the animation completes for the activity opening. You mention " Even the new animation functions of B4A 4.0 are supported" - if this was what you where talking about, how can I fix it so the ACxxxx controls also animate onto the screen?
     
  4. corwin42

    corwin42 Expert Licensed User

    The example is currently not updated to B4A6.0 and new AppCompat 3.20 library. I hope I find time to update the tutorials in the next days.

    Removing all #AdditionalRes lines was correct.

    For the error try to open the designer, load the layout file and save it again. This should fix the problem.

    The support for the Activity Layout Animation was removed with AppCompat 3.x library. There were too many hacks and workarounds in the library to support it. Just set the Activity animation time to 0 to disable the animation.
     
    Peter Simpson likes this.
  5. JohnCody

    JohnCody Well-Known Member Licensed User

    Cool. Thanks for the quick response. Even though my donation won't make you rich, I really do appreciate all your efforts in this forum :)
     
  6. Roberto P.

    Roberto P. Well-Known Member Licensed User

    Hello
    should I enter the Extends in all activity which uses components or is there a way to insert only one point in the entire program?

    thank you

     
  7. corwin42

    corwin42 Expert Licensed User

    You need to do it for every activity.
     
  8. Roberto P.

    Roberto P. Well-Known Member Licensed User

    ok, Thanks you
     
  9. trueboss323

    trueboss323 Active Member Licensed User

    Corwin how do you use the Add2 method for the ACSpinner? So far I am trying this code but it's not working:

    Code:
    Themespn.Add2("Blue",LoadBitmap(File.DirAssets,"spinicon.png"))
     
  10. corwin42

    corwin42 Expert Licensed User

    The second parameter is a Drawable and not a Bitmap. You can use this:

    Code:
    Dim bd As BitmapDrawable
    bd.Initialize(
    LoadBitmap(File.DirAssets, "spinicon.png"))
    Spinner.Add2("Itemname", bd)
     
    trueboss323 and DonManfred like this.
  11. johndb

    johndb Active Member Licensed User

    Is it possible to set an ACSpinner as a single line without wrapping if the text is longer than the ACSpinner view?

    Thank you,

    John
     
    GGSoft likes this.
  12. johndb

    johndb Active Member Licensed User

    @corwin42 Setting the ACSpinner Text Style "Horizontal Alignment" property has no effect and is always Center justified even when the property is set to LEFT or RIGHT alignment. This only applies to text that is wrapped to more that one line if the text is longer than the width of the ACSpinner. Would it be possible to have this corrected?
     
    Last edited: Nov 23, 2016
  13. Rubsanpe

    Rubsanpe Member Licensed User

    Hi. You can use

    Code:
    Dim cs As CSBuilder
    cs.Initialize.Alignment(
    "ALIGN_NORMAL").Append("Text").popall

    ACSpinner.Add(cs)
    Rubén
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice