小编use*_*095的帖子

更改Android Switch状态

我目前正在开发一个具有菜单的应用程序,菜单上的一个选项是"设置",用户基本上可以决定关闭声音和其他类似的东西.我目前在"设置"活动中有两个开关.到目前为止,这是Settings活动的java代码:

import android.support.v7.app.ActionBarActivity;


public class Options extends ActionBarActivity {
private  Switch ding;
private Switch countdown;
public  boolean isDingChecked;
public  boolean isCountdownChecked;
public static final String PREFS = "examplePrefs";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_options);
ding = (Switch) findViewById(R.id.switch1);
ding.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

        SharedPreferences examplePrefs = getSharedPreferences(PREFS,0);
        Editor editor = examplePrefs.edit();
        editor.putBoolean("userMessage", isChecked);
        editor.commit();

        //System.out.println(examplePrefs.getBoolean("userMessage", isChecked));
        isDingChecked = examplePrefs.getBoolean("userMessage", isChecked);
        System.out.println(isDingChecked + " is ding checked");
        ding.setChecked(isDingChecked);
    }
});

countdown = (Switch) findViewById(R.id.switch2); …
Run Code Online (Sandbox Code Playgroud)

android uiswitch android-activity

9
推荐指数
1
解决办法
4万
查看次数

在C++中有一个包含不同类型键的映射

我目前正在使用C++中的地图,并且有几个值是int和booleans,尽管它们中的大多数都是字符串.我知道在Java中我可以这样做:

std::map<string, Object*> mapvar;
Run Code Online (Sandbox Code Playgroud)

Object在C++中是否存在等价物?如果没有,有没有什么办法,我可以有正确的价值观是一个std::string,int或者bool

c++ types hashmap

1
推荐指数
1
解决办法
1899
查看次数

Python删除以特定单词开头的所有行

假设我有一个包含以下内容的字符串:

ASFksdfasf a
Oh sadfafas
Yeasd: asdfaf
Oh asdfaf
Run Code Online (Sandbox Code Playgroud)

我想从以“ Oh”开头的字符串中删除行。我将如何处理?现在我知道我可以在正则表达式中执行以下操作:

\b[Oh]\S*
Run Code Online (Sandbox Code Playgroud)

但是我不确定如何将结果存储到变量中,即使那样,我相信它只能找到单词,而不是删除单词。

python regex

1
推荐指数
2
解决办法
6716
查看次数

标签 统计

android ×1

android-activity ×1

c++ ×1

hashmap ×1

python ×1

regex ×1

types ×1

uiswitch ×1