Creating a Custom Expanded View in Code
I want to customize the notification area, adding an icon to the right and few buttons. I've read the tutorial here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html
The problem is that I need to include this code in a library, an SDK that I want to distribute to improve notifications. (See http://hub.buzzbox.com/)
Is it possible to write all the UI in code, without the need of the xml to describe the remote view? This is because resources cannot be included in an SDK, so I would need to ask the users of m开发者_StackOverflow社区y SDK to add an xml to their resources and to reference all the resources by name... which I would like to avoid. I've already written other parts of the SDK user interface completely in Java code but I'm having issues to do the same for the Remove View.
A RemoteView is usually created like this:
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
Can I create a RemoteView from I layout that I create with Java code? Any other solutions?
I thought that you might be able to do this with your own Parcel, but looking at the code, the Parcel simply stores the package name and layout (resource) id, as used by the main constructor.
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mPackage);
dest.writeInt(mLayoutId);
int count;
if (mActions != null) {
count = mActions.size();
} else {
count = 0;
}
dest.writeInt(count);
for (int i=0; i<count; i++) {
Action a = mActions.get(i);
a.writeToParcel(dest, 0);
}
}
I can't see a way of doing this and think it may not be possible.
精彩评论