花式展示案例视图

时间:2018-01-23 07:43:12

标签: android showcaseview

我想在我的应用程序中显示案例视图,在第一个展示页面中我想显示确认页面有两个按钮确定与否,如果确定则继续下一个显示案例,如果不是将删除/隐藏展示。但是我的ok按钮现在还不能正常工作,这是我的代码:

 // -------- First Show case ---------
 private void ShowCaseIntro(){
 mFancyShowCaseView = new FancyShowCaseView.Builder(this)
         .delay(1000)
         .customView(R.layout.tutorial, new OnViewInflateListener() {
             @Override
             public void onViewInflated(@NonNull View view) {

                 view.findViewById(R.id.btnNo).setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
                         mFancyShowCaseView.removeView();
                     }
                 });
                 view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
                         ShowCaseEditProfile();
                     }
                 });
             }
         }).closeOnTouch(false)
         .build();
 mFancyShowCaseView.show();
}

     // -------- Second Show case ---------
private void ShowCaseEditProfile (){
    mFancyShowCaseView = new FancyShowCaseView.Builder(this)
            .focusOn(imgEdit)
            .focusCircleRadiusFactor(2)
            .customView(R.layout.edit_tutorial, new OnViewInflateListener() {
                @Override
                public void onViewInflated(@NonNull View view) {
                    view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            mFancyShowCaseView.hide();
                        }
                    });
                }
            }).closeOnTouch(false)
            .build();
    mFancyShowCaseView.show();

}

这里我调用方法ShowCaseIntro():

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.activity_main);
    setDefaultToolbar(false);
    ShowCaseIntro();

}

这是按钮xml文件:

 <Button
            android:id="@+id/btnNo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="5dp"
            android:text="Tidak"
            android:textAllCaps="false"
            android:textColor="@color/colorPrimary" />

        <Button
            android:id="@+id/btnOK"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/btnNo"
            android:backgroundTint="@color/orange"
            android:text="OK !"
            android:textAllCaps="false"
            android:textColor="@color/white" />

1 个答案:

答案 0 :(得分:1)

当您致电ShowCaseEditProfile() mFancyShowCaseView时,您的ShowCaseEditProfile()已被附加,因此在致电mFancyShowCaseView.removeView();之前调用private void ShowCaseIntro(){ mFancyShowCaseView = new FancyShowCaseView.Builder(this) .delay(1000) .customView(R.layout.tutorial, new OnViewInflateListener() { @Override public void onViewInflated(@NonNull View view) { view.findViewById(R.id.btnNo).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mFancyShowCaseView.removeView(); } }); view.findViewById(R.id.btnOK).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //add this line mFancyShowCaseView.removeView(); ShowCaseEditProfile(); } }); } }).closeOnTouch(false) .build(); mFancyShowCaseView.show(); }

$sql = "SELECT * FROM moments"; 
$result = $conn->query($sql);
$summary = array();
while($row = mysqli_fetch_array($result)){               
    $summary[] = $row; 
}   
//var_dump($summary);