2012-06-15 31 views
0

我正在使用两个按钮的日期和时间。他们工作正常。但我需要添加更多按钮清除。点击清除按钮时,我的日期N时间按钮应该是空的(无日期N时间应显示)。如何清除重置按钮上的日期和时间

<Button 
    android:id="@+id/btn_qs_date" 
    style="@style/Text.Medium" 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:text="Thu, 15/03/2012" /> 

<Button 
    android:id="@+id/btn_qs_time" 
    style="@style/Text.Medium" 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:layout_marginLeft="10dp" 
    android:text="11:00 AM" /> 

<ImageButton 
    android:id="@+id/reset_date_time" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:layout_centerHorizontal="true" 
    android:layout_gravity="center" 
    android:layout_marginLeft="20dp" 
    android:background="@drawable/selector_reset_button" /> 

和我的Java代码是: -

case R.id.btn_reset_radio_test_grp: 

    rgYes.setChecked(false); 
    rgNo.setChecked(false); 
    break; 

case R.id.reset_date_time: 

    //i will have to write here 
break; 
+1

你说你需要让你的按钮没有显示文本时明确按钮被按下? –

回答

0
clearButton.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View v) { 
        btn_qs_date.setText(""); 
        btn_qs_time.setText(""); 
       } 
      }); 

哪里clearButton是你clearButton在UI

+0

感谢sana记住我。 –

相关问题