将可点击的跳过标签设置为对话框。单击时关闭对话框

时间:2014-01-20 09:33:28

标签: android

我的对话框显示了CountDowntimer。我想跳过该对话框上的标签,如果按下则忽略倒计时和对话框弹出窗口。启动下一个功能。

Timer_Dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<TextView 
    android:id="@+id/dialog_textview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:typeface="serif"
    android:textSize="25sp"
        />

<TextView
    android:id="@+id/dialog_skipLable"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:gravity="right"

    android:text="Skip"
    android:textSize="25sp"
    android:typeface="serif" />

</LinearLayout>

Javafile.java我在哪里写逻辑:

{
....
dialog=new Dialog(StartActivity.this);
dialog.setTitle("Exercise Starts in:");
dialog.setContentView(R.layout.timer_dialog); 
final TextView dialog_textview=(TextView)dialog.findViewById(R.id.dialog_textview);
dialog.show();
int brkTime=MainActivity.getBreackcountTime();
skipLable=(TextView) findViewById(R.id.dialog_skipLable);
        skipLable.setOnClickListener(onClickSkip);
brkTimer=new CountDownTimer(brkTime, 1000)
{
   public void onTick(long millisUntilFinished)
   {
   if(millisUntilFinished>0)
               {

                   dialog_textview.setText(millisUntilFinished / 1000+" seconds");
               }
               else
                   dialog_textview.setText(0+" seconds");
           }
        public void onFinish()
        {

            dialog.dismiss();
            runTimer();   
        }
        }.start();
.....
OnClickListener onClickSkip = new OnClickListener() {

            @Override
            public void onClick(View v)
            {


            brkTimer.cancel();
                 dialog.dismiss();



            }
        };

1 个答案:

答案 0 :(得分:0)

试试这个..

您正确地将final TextView dialog_textview=(TextView)dialog.findViewById(R.id.dialog_textview);作为 dialog.findViewById ,而不是skipLable

skipLable=(TextView) dialog.findViewById(R.id.dialog_skipLable);