是这样的:
因为要在Action Bar 上弄个 Switch 按钮,所以我照
http://stackoverflow.com/questions/12107031/how-to-add-a-switch-to-and...
的方法做了个.
现在做到按钮了,但却不能使用onCheckedChanged来验测按钮的开启
我该怎样做?
这是我实现Action Bar 上 放Switch 的代码
mainmenu.xml
menurelaty.xml
我在想:会不会是因为MainActivity上的setContentView是main_activity.xml而不是实现Switch的menurelaty.xml才不能以findViewByid然后.onCheckedChanged 来验测按钮的开启
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我也是参考这个来的,同样监听不到switch的onchangelistener
不过可以在onCreateOptionsMenu中监听即可
[java]
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.order, menu);
[/java]