0
当我打开droid时,我不想要任何按钮我只想要一系列图像自动显示,每个图像在被另一个图像替换之前几秒钟,显示的图像会将其循环回第一个图像。我对于机器人开发还是一个新东西,我显然错过了一些东西。任何帮助将不胜感激。我在创建droid中的自动幻灯片时遇到了麻烦
我的Java文件
public class Slidingpics2Activity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView image = (ImageView) findViewById(R.id.treat);
image.setBackgroundResource(R.drawable.theanime);
AnimationDrawable Anime = (AnimationDrawable) image.getBackground();
Anime.start();
}
}
我把theanime.xml文件中的文件夹绘制
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/image1" android:duration="1000" />
<item android:drawable="@drawable/image2" android:duration="1000" />
<item android:drawable="@drawable/image3" android:duration="1000" />
<item android:drawable="@drawable/image4" android:duration="1000" />
</animation-list>
,我疯了后我的布局main.xml中看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/treat"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
</LinearLayout>
冷静,我改变了ImageView的到Viewflipper,我现在看到的第一个图像,当我启动应用程序,但现在由于某种原因没有切换到第二个图像 – user1091368 2012-02-09 13:30:23
您需要在xml中使用'android:autoStart =“true”'和'android:flipInterval =“interval”'或者从您的java代码中设置自动启动和flipinterval变量:'flipper.setFlipInterval(milliseconds )'和'setAutoStart(true)'(或'startFlipping()') – Jave 2012-02-09 13:34:57
尝试** setAutoStart(true)**&'startFlipping()'我仍然有同样的问题 这就是我如何设置 'ViewFlipper image =(ViewFlipper)findViewById(R.id.treat); image.setBackgroundResource(R.drawable.theanime); image.setFlipInterval(5000); image.setAutoStart(true); } }' – user1091368 2012-02-09 14:15:31