RemoteViews的使用
来源:互联网 发布:淘宝售后工作职责 编辑:程序博客网 时间:2024/06/07 01:48
RemoteViews中的setxxx方法
比如setCharSequence(int viewId, String methodName, CharSequence value);
views.setString(R.id.textview01, "setText", battery + "%");
其中views是RomoteViews的实例,
第一个参数就是ID了,
第二个参数,是一个方法名字,比如这里是textView,那么textView会有很多方法,比如setBackground(), setText(), setTextColor()等等,第二个参数就填这个函数名,不要括号,
第三个参数就填第二个函数所用到的参数,比如如果是setTextColor(int), 第三个参数就带int进去(当然如果是这个你就必须用views.setInt(...)这个函数)
【以下是转载】
RemoteViews 类描述了一个View对象能够显示在其他进程中,可以融合从一个 layout资源文件实现布局。虽然该类在android.widget.RemoteViews而不是appWidget下面但在Android Widgets开发中会经常用到它,主要是可以跨进程调用(appWidget由一个服务宿主来统一运行的)。
如何实例化一个RemoteViews
构造方法
RemoteViews(String packageName, int layoutId)
创建一个新的RemoteViews 对象将显示 views包含指定一个layout资源.
RemoteViews(Parcel parcel)
读取RemoteViews对象从一个parcel中.
首先给大家一段例子简单说明下构造和如何使用
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider);
views.setTextViewText(R.id.appwidget_text, "Android开发网欢迎您");
appWidgetManager.updateAppWidget(appWidgetId, views);
详细的 该类的公共方法列表,下面的viewId为layout文件中的id定义,常用的方法已经翻译成中文描述。
Public Methods
View apply(Context context, ViewGroup parent)
Inflates the view hierarchy represented by this object and applies all of the actions.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
int getLayoutId()
String getPackage()
boolean onLoadClass(Class clazz)
Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
void reapply(Context context, View v)
Applies all of the actions to the provided view.
void setBitmap(int viewId, String methodName, Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
void setBoolean(int viewId, String methodName, boolean value)
Call a method taking one boolean on a view in the layout for this RemoteViews.
void setByte(int viewId, String methodName, byte value)
Call a method taking one byte on a view in the layout for this RemoteViews.
void setChar(int viewId, String methodName, char value)
Call a method taking one char on a view in the layout for this RemoteViews.
void setCharSequence(int viewId, String methodName, CharSequence value)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
void setChronometer(int viewId, long base, String format, boolean started)
Equivalent to calling Chronometer.setBase, Chronometer.setFormat, and Chronometer.start() or Chronometer.stop().
void setDouble(int viewId, String methodName, double value)
Call a method taking one double on a view in the layout for this RemoteViews.
void setFloat(int viewId, String methodName, float value)
Call a method taking one float on a view in the layout for this RemoteViews.
void setImageViewBitmap(int viewId, Bitmap bitmap)
等同于调用ImageView.setImageBitmap方法,从Bitmap对象中设置一个图片
void setImageViewResource(int viewId, int srcId)
等同于调用ImageView.setImageResource,从一个资源中设置图片
void setImageViewUri(int viewId, Uri uri)
等同于调用ImageView.setImageURI,从URI中设置图像
void setInt(int viewId, String methodName, int value)
Call a method taking one int on a view in the layout for this RemoteViews.
void setLong(int viewId, String methodName, long value)
Call a method taking one long on a view in the layout for this RemoteViews.
void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
Equivalent to calling setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent.
void setProgressBar(int viewId, int max, int progress, boolean indeterminate)
等同于调用ProgressBar.setMax, ProgressBar.setProgress, and ProgressBar.如果indeterminate为true则进度条的最大和最小进度将会忽略
void setShort(int viewId, String methodName, short value)
Call a method taking one short on a view in the layout for this RemoteViews.
void setString(int viewId, String methodName, String value)
Call a method taking one String on a view in the layout for this RemoteViews.
void setTextColor(int viewId, int color)
等同于setTextColor(int).,设置文本的颜色
void setTextViewText(int viewId, CharSequence text)
等同于TextView.setText,设置文本内容
void setUri(int viewId, String methodName, Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews.
void setViewVisibility(int viewId, int visibility)
等同于调用View.setVisibility,设置该ID控件的可见性
void writeToParcel(Parcel dest, int flags)
比如setCharSequence(int viewId, String methodName, CharSequence value);
views.setString(R.id.textview01, "setText", battery + "%");
其中views是RomoteViews的实例,
第一个参数就是ID了,
第二个参数,是一个方法名字,比如这里是textView,那么textView会有很多方法,比如setBackground(), setText(), setTextColor()等等,第二个参数就填这个函数名,不要括号,
第三个参数就填第二个函数所用到的参数,比如如果是setTextColor(int), 第三个参数就带int进去(当然如果是这个你就必须用views.setInt(...)这个函数)
【以下是转载】
RemoteViews 类描述了一个View对象能够显示在其他进程中,可以融合从一个 layout资源文件实现布局。虽然该类在android.widget.RemoteViews而不是appWidget下面但在Android Widgets开发中会经常用到它,主要是可以跨进程调用(appWidget由一个服务宿主来统一运行的)。
如何实例化一个RemoteViews
构造方法
RemoteViews(String packageName, int layoutId)
创建一个新的RemoteViews 对象将显示 views包含指定一个layout资源.
RemoteViews(Parcel parcel)
读取RemoteViews对象从一个parcel中.
首先给大家一段例子简单说明下构造和如何使用
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider);
views.setTextViewText(R.id.appwidget_text, "Android开发网欢迎您");
appWidgetManager.updateAppWidget(appWidgetId, views);
详细的 该类的公共方法列表,下面的viewId为layout文件中的id定义,常用的方法已经翻译成中文描述。
Public Methods
View apply(Context context, ViewGroup parent)
Inflates the view hierarchy represented by this object and applies all of the actions.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
int getLayoutId()
String getPackage()
boolean onLoadClass(Class clazz)
Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
void reapply(Context context, View v)
Applies all of the actions to the provided view.
void setBitmap(int viewId, String methodName, Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
void setBoolean(int viewId, String methodName, boolean value)
Call a method taking one boolean on a view in the layout for this RemoteViews.
void setByte(int viewId, String methodName, byte value)
Call a method taking one byte on a view in the layout for this RemoteViews.
void setChar(int viewId, String methodName, char value)
Call a method taking one char on a view in the layout for this RemoteViews.
void setCharSequence(int viewId, String methodName, CharSequence value)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
void setChronometer(int viewId, long base, String format, boolean started)
Equivalent to calling Chronometer.setBase, Chronometer.setFormat, and Chronometer.start() or Chronometer.stop().
void setDouble(int viewId, String methodName, double value)
Call a method taking one double on a view in the layout for this RemoteViews.
void setFloat(int viewId, String methodName, float value)
Call a method taking one float on a view in the layout for this RemoteViews.
void setImageViewBitmap(int viewId, Bitmap bitmap)
等同于调用ImageView.setImageBitmap方法,从Bitmap对象中设置一个图片
void setImageViewResource(int viewId, int srcId)
等同于调用ImageView.setImageResource,从一个资源中设置图片
void setImageViewUri(int viewId, Uri uri)
等同于调用ImageView.setImageURI,从URI中设置图像
void setInt(int viewId, String methodName, int value)
Call a method taking one int on a view in the layout for this RemoteViews.
void setLong(int viewId, String methodName, long value)
Call a method taking one long on a view in the layout for this RemoteViews.
void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
Equivalent to calling setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent.
void setProgressBar(int viewId, int max, int progress, boolean indeterminate)
等同于调用ProgressBar.setMax, ProgressBar.setProgress, and ProgressBar.如果indeterminate为true则进度条的最大和最小进度将会忽略
void setShort(int viewId, String methodName, short value)
Call a method taking one short on a view in the layout for this RemoteViews.
void setString(int viewId, String methodName, String value)
Call a method taking one String on a view in the layout for this RemoteViews.
void setTextColor(int viewId, int color)
等同于setTextColor(int).,设置文本的颜色
void setTextViewText(int viewId, CharSequence text)
等同于TextView.setText,设置文本内容
void setUri(int viewId, String methodName, Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews.
void setViewVisibility(int viewId, int visibility)
等同于调用View.setVisibility,设置该ID控件的可见性
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
原文地址:http://hi.baidu.com/liujianzhang85/item/7aaee2fa78a6df0de2e3bdd6
- RemoteViews的使用
- RemoteViews的使用
- RemoteViews使用
- 022.RemoteViews的介绍和使用
- (十一)RemoteViews的使用解析
- 使用RemoteViews自定义Notification
- RemoteViews使用setImageResource出错
- RemoteViews之RemoteViews的内部机制
- RemoteViews在桌面小部件和通知栏的使用
- Android RemoteViews的基本使用(上)之通知栏
- Android RemoteViews的基本使用(下)之窗口小部件
- Android的RemoteViews
- RemoteViews的应用
- RemoteViews的用处
- RemoteViews的解析
- RemoteViews的用途
- RemoteViews的内部机制
- RemoteViews的简单应用
- 3Sum Closest
- OpenStack对象存储-swift
- c语言版数据结构(奇迹冬瓜)-链表实战(2)合并两有序线性表
- 将代码以Eval方式加密、解密
- 常用的Double保留N位小数的转换
- RemoteViews的使用
- shell编程——循环语句
- JAVA序列化与反序列化三种格式存取(默认格式、XML格式、JSON格式)
- SPOJ 1182. Sorted bit squence (数位统计+二分)
- shell 编程——for in 循环
- 我对linux理解之framebuffer
- C++笔记(三)重载操作符
- MySQL Partition扫盲
- Shell 函数