allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.VictorAlbertos:BreadcrumbsView:0.0.4'
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp">
<io.victoralbertos.breadcumbs_view.BreadcrumbsView
android:id="@+id/breadcrumbs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:heightSeparator="1dp"
app:nextStepBorderDotColor="#30FF9800"
app:nextStepFillDotColor="#30FF9800"
app:nextStepSeparatorColor="#30FF9800"
app:numberOfSteps="5"
app:radiusDot="5dp"
app:sizeDotBorder="1dp"
app:visitedStepBorderDotColor="#F57C00"
app:visitedStepFillDotColor="#F57C00"
app:visitedStepSeparatorColor="#F57C00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/bt_prev"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#F57C00"
android:text="PREV"
android:textColor="#ffffff" />
<Button
android:id="@+id/bt_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#F57C00"
android:text="NEXT"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import io.victoralbertos.breadcumbs_view.BreadcrumbsView;
public class BreadActivity extends AppCompatActivity {
private Integer cacheCurrentStep;
private BreadcrumbsView breadcrumbsView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bread);
if (onRetainCustomNonConfigurationInstance() == null) {
cacheCurrentStep = 0;
} else {
cacheCurrentStep = (Integer) onRetainCustomNonConfigurationInstance();
}
breadcrumbsView = (BreadcrumbsView) findViewById(R.id.breadcrumbs);
breadcrumbsView.setCurrentStep(cacheCurrentStep);
findViewById(R.id.bt_next).setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
if (breadcrumbsView.getCurrentStep()==4){
return;
}
breadcrumbsView.nextStep();
}
});
findViewById(R.id.bt_prev).setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
if (breadcrumbsView.getCurrentStep()==0){
return;
}
breadcrumbsView.prevStep();
}
});
}
//Survive config changes.
@Override public Object onRetainCustomNonConfigurationInstance() {
return breadcrumbsView.getCurrentStep();
}
}
网友评论