This library is now in a usable condition and may evolve as requirements increase.
License:
You are free to use this library in commercial/non-commericial projects. If you use it for something cool, it would be nice if you could post a screenshot of your app using this library on the forum (probably Share Your Creations).
You may use the source code and add new functions to it. If you do so, you are required to post the improvements/additions in this thread.
Usage:
1. The Layout of the Notification
This is defined in an xml layout file. Create your layout, name it to "cm.xml" and copy it to your projects Objects/res/Layout folder. Mark it as read-only. See XML Resources for further information.
Make sure you give an id to each view in the xml, because in order to set these views we will use the same id.
If you have trouble with the xml file (like I did), do Clean Project. Make the xml file in utf-8. warwound used dreamweaver for mine.
2. Add the Library to your project
Right hand pane, contains a library tab. Select "CustomNotifications"
3. B4A Code
Create a notification object as you normally would.
Then to customize it, do:
The id used here to set the properties, is the same id defined in your xml layout.
Still having problems?
Before posting a question, check and double check your xml file.
Most errors happen due to your xml file not being added as a resource. Look in the Objects/gen/<packagename>/R.java file to see it the xml file is being added into it.
Then read this link carefully and thoroughly: Custom Notifcation Layouts
Also dont try to put a listview or a scrollview in a notification. It only supports buttons, labels, progressbars, imageviews and panels. There may be other restrictions on what it supports.
XML Resources:
Learn about xml layouts and styles. Each ROM has a different style so it could cause your text to be invisible.
Custom Notifcation Layouts
LinearLayout
Shortcomings:
Events based on individual view clicks. This requires pending intents, so far I havent been able to make it work. Please let me know if you have a solution.
Credits:
There are too many people who deserve credits for this.
Erel (the platform), Barx(the enlightenment), corwin42(the functions), warwound(the xml file), NJDude(the banter), XverhelstX(the nagging), JonPM(the initial inspiration) and many others I may have forgot to mention.
___________________________________________
Important Notice:
This library is depreciated and is left here as an archive/legacy reasons. This has been superseded by this library: Custom Notification Library: Barx
License:
You are free to use this library in commercial/non-commericial projects. If you use it for something cool, it would be nice if you could post a screenshot of your app using this library on the forum (probably Share Your Creations).
You may use the source code and add new functions to it. If you do so, you are required to post the improvements/additions in this thread.
Usage:
1. The Layout of the Notification
This is defined in an xml layout file. Create your layout, name it to "cm.xml" and copy it to your projects Objects/res/Layout folder. Mark it as read-only. See XML Resources for further information.
Make sure you give an id to each view in the xml, because in order to set these views we will use the same id.
B4X:
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
2. Add the Library to your project
Right hand pane, contains a library tab. Select "CustomNotifications"
3. B4A Code
Create a notification object as you normally would.
Then to customize it, do:
B4X:
Dim cn as CustomNotification
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo("Hello","hello","")
cn.setCustomView(n)
cn.setText(n,"title","NewTitle")
cn.setText(n,"text","NewText")
cn.setTextColor(n,"text",Colors.Red)
cn.setTextSize(n,"title",20)
cn.setImage(n,"image",c.Bitmap)
The id used here to set the properties, is the same id defined in your xml layout.
Still having problems?
Before posting a question, check and double check your xml file.
Most errors happen due to your xml file not being added as a resource. Look in the Objects/gen/<packagename>/R.java file to see it the xml file is being added into it.
Then read this link carefully and thoroughly: Custom Notifcation Layouts
Also dont try to put a listview or a scrollview in a notification. It only supports buttons, labels, progressbars, imageviews and panels. There may be other restrictions on what it supports.
XML Resources:
Learn about xml layouts and styles. Each ROM has a different style so it could cause your text to be invisible.
Custom Notifcation Layouts
LinearLayout
Shortcomings:
Events based on individual view clicks. This requires pending intents, so far I havent been able to make it work. Please let me know if you have a solution.
Credits:
There are too many people who deserve credits for this.
Erel (the platform), Barx(the enlightenment), corwin42(the functions), warwound(the xml file), NJDude(the banter), XverhelstX(the nagging), JonPM(the initial inspiration) and many others I may have forgot to mention.
___________________________________________
Important Notice:
This library is depreciated and is left here as an archive/legacy reasons. This has been superseded by this library: Custom Notification Library: Barx
Attachments
Last edited: