我有一个Android应用程序,在一个屏幕上,我们有2.x的ToggleButton和4.x的开关。我能够为版本layout-v14等创建布局文件夹,并且布局xml的工作正常。
我关注的是从编码的角度来看,我希望能够从代码中获取组件(switch或togglebutton)并让它在API 10及更高版本中运行。但是,较旧的API没有android.widget.switch。还有其他工作吗?否则,我必须向所有用户显示ToggleButton :(
我为此深感阅读以下内容:
http://www.edumobile.org/android/android-tutorial/switches-example-in-android/
http://developer.android.com/guide/topics/ui/controls/togglebutton.html
答案 0 :(得分:0)
我明白了。他们都继承自CompoundButton
。因此可以导入android.widget.CompoundButton
。无需导入ToggleButton
或Switch
。案件结案。