根据android.developer网站ViewFlipper
支持RemoreViews
所以我决定制作一个简单的Widget来显示修复图片,我希望用户通过提供{{1来制作然后开始和停止}}
现在我的问题是Button
没有ViewFlipper
和startFlipping()
方法作为RemoteMethod,因此决定使用我自己的自定义stopFlipping()
来调用ViewFlipper
和startFlipping()
来自stopFlipping()
,因为它是RemoteMethod。
这是我的自定义setFlipInterval
类。
ViewFlipper
及以下是@RemoteView
public class PhotoViewFliper extends ViewFlipper {
public static final int STOP_FLIP = -11;
public static final int START_FLIP = -12;
public String TAG = PhotoViewFliper.class.getCanonicalName();
public PhotoViewFliper(Context _Context) {
// TODO Auto-generated constructor stub
super(_Context);
}
public PhotoViewFliper(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public void stopFlipping() {
super.stopFlipping();
Log.d(TAG, "stopFlipping--My Called ");
}
@Override
public void setVisibility(int visibility) {
// TODO Auto-generated method stub
super.setVisibility(visibility);
}
@Override
public void setFlipInterval(int milliseconds) {
Log.d(TAG, "setFlipInterval--My Called " + milliseconds);
switch (milliseconds) {
case STOP_FLIP:
stopFlipping();
Log.d(TAG, "In Side Switch stopFlipping--My Called ");
break;
case START_FLIP:
startFlipping();
Log.d(TAG, "In Side Switch startFlipping--My Called ");
break;
default:
super.setFlipInterval(milliseconds);
}
}
}
Widget
以下是我的错误记录标签
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="10dp" >
<com.photos.widget.PhotoViewFliper
android:id="@+id/vflipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoStart="true"
android:background="@drawable/bg_white_boarder"
android:flipInterval="3000"
android:inAnimation="@anim/in_from_right"
android:outAnimation="@anim/out_to_left" >
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/widget_examples" />
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/tad_logo_com" />
</com.photos.widget.PhotoViewFliper>
<ImageView
android:id="@+id/btn_play_pause"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="bottom|center_horizontal"
android:src="@drawable/ic_av_pause_over_video" />
</FrameLayout>
答案 0 :(得分:0)
仔细阅读:http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
&#34;不支持这些类的后代。&#34;