Попытка заставить кнопку появиться после того, как индикатор выполнения достигнет максимума (100%), но приложение по какой-то причине вылетает. Я могу изменить цвет и сделать его невидимым после загрузки индикатора выполнения, но по какой-то причине не сделать его видимым, пожалуйста, помогите!
Вот код class.java:
int progress = 0;
ProgressBar simpleProgressBar;
Button startB = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_enteredring_page);
// initiate progress bar and start button
simpleProgressBar = (ProgressBar) findViewById(R.id.loadingfightbar);
setProgressValue(progress);
startB = (Button)findViewById(R.id.showfight);
// startB.setVisibility(View.VISIBLE);
View overlay = findViewById(R.id.inringlayout);
overlay.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
VideoView mVideoView = (VideoView) findViewById(R.id.videoView);
String uriPath = "android.resource://com.seth.boxingadventure.boxerapp/" + R.raw.hayahadvid;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
}
private void setProgressValue(final int progress) {
// set the progress
simpleProgressBar.setProgress(progress);
// thread is used to change the progress value
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
if(simpleProgressBar.getProgress() == simpleProgressBar.getMax())
{
// startB.setVisibility(View.VISIBLE);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
setProgressValue(progress + 10);
}
});
thread.start();
}
}
И xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:id="@+id/inringlayout"
android:weightSum="1">
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="318dp"
android:layout_weight="0.87" />
<ProgressBar
android:id="@+id/loadingfightbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:angle="270"
android:centerColor="#C27452"
android:centerY="0.75"
android:endColor="#050505"
android:startColor="#F0500A"
android:visibility="visible"
tools:visibility="visible"
android:layout_below="@+id/videoView"
android:layout_centerHorizontal="true"
android:layout_marginTop="81dp"
android:max="100"
android:progress="50"
/>
<Button
android:id="@+id/showfight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:visibility="invisible"
android:layout_marginBottom="17dp" />