我走在Android编程Coursera类。 这里是什么,我试图做一个说明...
这里是我到目前为止的代码...
XML:
<Button
android:id="@+id/startbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/leftfoot"
android:layout_alignRight="@+id/leftfoot"
android:onClick="startRhythmandAnimation"
android:text="@string/start_button" />
Java的:
public class Assignment3MainActivity extends Activity {
private View mMileTimeGoal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_assignment3_main);
mMileTimeGoal = findViewById(R.id.miletimegoal);
}
public void startRhythmandAnimation () {
String MileTime = mMileTimeGoal.getContext().toString();
String[] time_array = MileTime.split(":");
int hours = Integer.parseInt(time_array[0]);
int minutes = Integer.parseInt(time_array[1]);
int seconds = Integer.parseInt(time_array[2]);
int duration = 3600 * hours + 60 * minutes + seconds;
int steps_per_second = 3;
int running_rate = duration * steps_per_second;
View rightfoot = findViewById(R.id.rightfoot);
View leftfoot = findViewById(R.id.leftfoot);
rightfoot.setVisibility(View.VISIBLE);
Animation anim = AnimationUtils.makeInChildBottomAnimation(this);
rightfoot.startAnimation(anim);
leftfoot.setVisibility(View.VISIBLE);
leftfoot.startAnimation(anim);
}
如何形成我的算法,这将滑动和淡出我的rightfoot观点和看法leftfoot任何想法?
我应该使用一个while循环,并揭开序幕某种类型的计时器?