mytogglesample github

内容纲要

在上一个toggle的启发下 我也整合了一个控件~欢迎安卓开发者一起探讨~

下载地址 https://github.com/Sky-J/mytogglesample

mytogglesample

 这个是一个安卓的togglebutton
使用方法~

在layout中添加xml

   <com.example.mytogglesample.MyToggle        android:id="@+id/MyToggle1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </com.example.mytogglesample.MyToggle>

设置它的触发器

myToggle=(MyToggle)findViewById(R.id.MyToggle1);
myToggle.setOnToggleChanged(new OnToggleChanged()
{
    @Override
    public void onToggle(boolean on)
    {        if (on)            Toast.makeText(getApplicationContext(), "yes", Toast.LENGTH_LONG).show();        else
        {            Toast.makeText(getApplicationContext(), "no", Toast.LENGTH_LONG).show();
        }
    }
});

发表回复