主页>Android开发> 正文
RemoteViews - Android Widget开发入门
- 发布时间:2009-07-04
- 作者:Android开发网原创

RemoteViews类描述了一个View对象能够显示在其他进程中,可以融合从一个 layout资源文件实现布局。虽然该类在android.widget.RemoteViews而不是appWidget下面但在Android Widgets开发中会经常用到它,主要是可以跨进程调用(appWidget由一个服务宿主来统一运行的)。
如何实例化一个RemoteViews
| 构造方法 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
创建一个新的RemoteViews 对象将显示 views包含指定一个layout资源.
|
|||||||||||
读取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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Inflates the view hierarchy represented by this object and applies all of the actions.
|
|||||||||||
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
|
|||||||||||
Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
|
|||||||||||
Applies all of the actions to the provided view.
|
|||||||||||
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one boolean on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one byte on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one char on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
|
|||||||||||
Equivalent to calling Chronometer.setBase, Chronometer.setFormat, and Chronometer.start() or Chronometer.stop().
|
|||||||||||
Call a method taking one double on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one float on a view in the layout for this RemoteViews.
|
|||||||||||
等同于调用ImageView.setImageBitmap方法,从Bitmap对象中设置一个图片
|
|||||||||||
等同于调用ImageView.setImageResource,从一个资源中设置图片
|
|||||||||||
等同于调用ImageView.setImageURI,从URI中设置图像
|
|||||||||||
Call a method taking one int on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one long on a view in the layout for this RemoteViews.
|
|||||||||||
Equivalent to calling setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent.
|
|||||||||||
等同于调用ProgressBar.setMax, ProgressBar.setProgress, and ProgressBar.如果indeterminate为true则进度条的最大和最小进度将会忽略
|
|||||||||||
Call a method taking one short on a view in the layout for this RemoteViews.
|
|||||||||||
Call a method taking one String on a view in the layout for this RemoteViews.
|
|||||||||||
等同于setTextColor(int).,设置文本的颜色
|
|||||||||||
等同于TextView.setText,设置文本内容
|
|||||||||||
Call a method taking one Uri on a view in the layout for this RemoteViews.
|
|||||||||||
等同于调用View.setVisibility,设置该ID控件的可见性
|
|||||||||||
Flatten this object in to a Parcel.
|
|||||||||||