有没有办法在动作栏中设置倒数计时器的进度条?
我可以通过
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(...);
setProgressBarIndeterminateVisibility(true);
我可以通过
在MenuItem中设置倒数计时器(TextView)private void startTimer(long duration, long interval) {
timer = new CountDownTimer(duration, interval) {
@Override
public void onFinish() {
//Kills current Activity
finish();
}
@Override
public void onTick(long millisecondsLeft) {
int secondsLeft = (int) Math.round((millisecondsLeft / (double) 1000));
MenuItem timerItem = mMenu.findItem(R.id.timer_item);//Where mMenu is the menu inflated
timerItem.setTitle(secondsLeft+"");
}
};
timer.start();
}
menu.xml文件
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compatibility="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/timer_item"
name="android:actionMenuTextAppearance"
android:showAsAction="always"
compatibility:actionViewClass="android.widget.TextView"/>
</menu>
任何人都可以建议我如何整合这两个一个带倒数计时器的进度条(在操作栏上)??