任何人都可以帮我解决下面的java代码,因为我想创建一个图片幻灯片,而无需点击按钮。我希望视图翻板能够自动切换不同的iamges,而无需单击按钮。我希望它能够一次又一次地显示所有图像,而无需单击按钮。我删除了我的XML文件中的按钮,因为我不需要它。
Java文件代码
modDropOff = Now
LHour = Hour("4:00:00 PM")
LNewHour = Hour("07:00:00 AM")
If Weekday(Date) = vbFriday And Now() >= LHour Then
modDropOff = Date + 3 <<< + LNewHour
End If
XML文件
public class MainActivity extends Activity {
int mFlipping = 0 ; // Initially flipping is off
Button mButton ; // Reference to button available in the layout to start and stop the flipper
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/** Click event handler for button */
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v) {
ViewFlipper flipper = (ViewFlipper) findViewById(R.id.flipper1);
if(mFlipping==0){
/** Start Flipping */
flipper.startFlipping();
mFlipping=1;
mButton.setText(R.string.str_btn_stop);
}
else{
/** Stop Flipping */
flipper.stopFlipping();
mFlipping=0;
mButton.setText(R.string.str_btn_start);
}
}
};
/** Getting a reference to the button available in the resource */
mButton = (Button) findViewById(R.id.btn);
/** Setting click event listner for the button */
mButton.setOnClickListener(listener);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
答案 0 :(得分:0)
For(int mflipping:0; mflipping less than total images-1 length; mflipping ++) 卷曲的开始 Flipper.startflipping(); //延迟一段时间 卷曲的Brases结束 Flipper.stopflipping();
Sodu代码,现在编写代码
答案 1 :(得分:0)
只需删除按钮侦听器并尝试。
public class MainActivity extends Activity {
int mFlipping = 0 ; // Initially flipping is off
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ViewFlipper flipper = (ViewFlipper) findViewById(R.id.flipper1);
if(mFlipping==0){
/** Start Flipping */
flipper.startFlipping();
mFlipping=1;
}
else{
/** Stop Flipping */
flipper.stopFlipping();
mFlipping=0;
}
}
};
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}