Java Question Wrapping Library with xml files required

walterf25

Expert
Licensed User
Longtime User
Hello all, i'm trying to wrap a CircularProgressBar library, i'm just trying to do this for fun, i've wrapped a few other libraries before but i'm a little confused with this library, since it requires a few xml libraries to be included. Here's what i have so far.

B4X:
package com.genesis.circularprogressbar;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

import com.lylc.widget.circularprogressbar.example.CircularProgressBar;



@Version(1.0f)
@ShortName("B4ACircularProgressBar")
@ActivityObject
@Permissions(values={"android.permission.INTERNET"})
@Author("Walter F")
@DependsOn(values = { "CircularProgressBar" })

public class B4ACircularProgressBar {
   
    public void Initialize(BA ba, String eventname){
        CircularProgressBar c1 = new CircularProgressBar(ba.context);
        c1.setProgress(45);
    }

}

The library compiles just fine in Eclipse, but i get a Resource Not found error when I try to use it in my B4A project, of course this has to do with the xml files that are needed.

How can I call this files or include them in my project so that i get rid of this error?

I know it might be a simple answer, but my brain keeps farting at the moment.

I'd really appreciate it if anyone can point me in the right direction.

The original project can be found here.https://github.com/ylyc/circular_progress_bar

Thanks everyone in Advance.

Cheers,
Walter
 

Theera

Well-Known Member
Licensed User
Longtime User
I would love to know this too. I 'm not understand how to create library(How to convert) when we have the original project. Please give me only example. I think I will clearly.

Should I start at this java file ?


@Walter I think it should be below.
import com.lylc.widget.circularprogressbar.example;
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
@Erel I've be understand 2 examples in simplewrapper tool. The first,it is easy function,the second,it is sdk and has jar file . And the third is this which I still not understand how to create it.
 

walterf25

Expert
Licensed User
Longtime User
Have you tried to copy the resource files to your project Objects\res (and make them readonly)?
Hi Erel, yes i tried copying the resource files to my objects/res folder, but it doesn't seem to work.

Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Thanks for that tip tds, i will try that.

Cheers,
Walter
 

walterf25

Expert
Licensed User
Longtime User
I used the extend viewWrapper<CircularProgressBar> and also tried the AdditionalRes attribute but i get this error.


Any Ideas?
 

walterf25

Expert
Licensed User
Longtime User
Now I get this error

I excluded the res folder from the eclipse project.

I also used the AdditionalRes Attribute in my b4a project, but i get the error below.

Any suggestions please?

Walter
 

Attachments

  • error.jpg
    206.4 KB · Views: 212

walterf25

Expert
Licensed User
Longtime User
Hi Guys again, i got the library working, but i want to expand and expose all of the functionalities, right now i can only display the basic circular progressbar but in the original project, I see that there are various styles declared in the activity_main.xml file, i need to know how to load those different layouts from code. Can anyone please help me with this. I tries this but i get a null exception error when i run my b4a project.

B4X:
String resourceName="circularprogressbar2";
        int resourceId = BA.applicationContext.getResources().getIdentifier(resourceName, "id", BA.packageName);
        BA.Log("ResourceID " + resourceId);
final CircularProgressBar c2 = (CircularProgressBar) new CircularProgressBar(ba.context).findViewById(R.id.circularprogressbar2);

on the original project they call it like this
B4X:
final CircularProgressBar c2 = (CircularProgressBar) findViewById(R.id.circularprogressbar2);

This is the error I get now


Hope I make sense, thanks all.

Any ideas?

Cheers,
Walter
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Never Mind again, i also figured it out, haha.

I will post the library once i'm done.

this is how i did it.

B4X:
final CircularProgressBar c2 = (CircularProgressBar) new CircularProgressBar(ba.context, null, BA.applicationContext.getResources().getIdentifier(resourceName, "layout", BA.packageName));

Thanks,
walter
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…