在谷歌浏览器中,有一种简单的方法可以查看本地存储中的内容,以及在检查后修改或删除它.
在Firefox中是否有工具或其他相同的功能?
我有两个变量:
site1 = "www.somesite.com";
site2 = "www.somesite.com/";
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情
function someFunction(site)
{
// If the var has a trailing slash (like site2),
// remove it and return the site without the trailing slash
return no_trailing_slash_url;
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
这是我的代码:
在onCreate:
new LoadMusicInBackground().execute();
Run Code Online (Sandbox Code Playgroud)
然后在我的主要课程结束时,我有这个代码
/** Helper class to load all the music in the background. */
class LoadMusicInBackground extends AsyncTask<Void, String, Void> {
@Override
protected Void doInBackground(Void... unused) {
soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 100);
soundPoolMap = new HashMap<Integer, Integer>();
soundPoolMap.put(A1,
soundPool.load(GameScreen_bugfix.this, R.raw.a, 1));
soundPoolMap.put(A3,
soundPool.load(GameScreen_bugfix.this, R.raw.b, 1));
soundPoolMap.put(A5,
soundPool.load(GameScreen_bugfix.this, R.raw.c_s, 1));
soundPoolMap.put(A6,
soundPool.load(GameScreen_bugfix.this, R.raw.d, 1));
soundPoolMap.put(A8,
soundPool.load(GameScreen_bugfix.this, R.raw.e, 1));
soundPoolMap.put(A10,
soundPool.load(GameScreen_bugfix.this, R.raw.f_s, 1));
soundPoolMap.put(A12,
soundPool.load(GameScreen_bugfix.this, R.raw.g_s, 1));
soundPoolMap.put(wrong,
soundPool.load(GameScreen_bugfix.this, R.raw.wrong2, 1));
publishProgress("");
Log.v("SOUNDPOOL", "" + soundPoolMap);
return (null); …Run Code Online (Sandbox Code Playgroud) 根据我的理解,要确定是否"单击"复选框并查找是否已选中,可以使用以下代码:
cb=(CheckBox)findViewById(R.id.chkBox1);
cb.setOnCheckedChangeListener(this);
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
cb.setText("This checkbox is: checked");
}
else {
cb.setText("This checkbox is: unchecked");
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何对无线电组进行上述操作的逻辑.
这是我的RadioGroup的xml:
<RadioGroup android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radio1" android:checked="true"
android:text="RadioButton1">
</RadioButton>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radio2" android:text="RadioButton2" android:checked="true">
</RadioButton>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radio3" android:text="RadioButton3">
</RadioButton>
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
问题:我是否需要设置另一个监听器,或者监听器是否已经"注册"了这个组?
此外,应该在RadioGroup还是RadioButton上设置监听器?
android listener radio-group android-radiogroup android-radiobutton
我还在学习OOP所以这甚至可能都不可能(虽然我会感到惊讶),我需要一些帮助调用另一个类方法.
例如,ClassA I有这个方法:
function getName()
{
return $this->name;
}
Run Code Online (Sandbox Code Playgroud)
现在从ClassB(不同的文件,但在同一目录下),我要打电话ClassA的getName(),我该怎么做呢?我试图做一个,include()但这不起作用.
谢谢!
如果有一件事我无法理解,那就是正则表达式.
经过大量的搜索,我终于找到了适合我需求的产品:
function get_domain_name()
{
aaaa="http://www.somesite.se/blah/sdgsdgsdgs";
//aaaa="http://somesite.se/blah/sese";
domain_name_parts = aaaa.match(/:\/\/(.[^/]+)/)[1].split('.');
if(domain_name_parts.length >= 3){
domain_name_parts[0] = '';
}
var domain = domain_name_parts.join('.');
if(domain.indexOf('.') == 0)
alert("1"+ domain.substr(1));
else
alert("2"+ domain);
}
Run Code Online (Sandbox Code Playgroud)
它基本上给了我回域名,反正我还能得到域名之后的所有东西吗?在这种情况下,它将/blah/sdgsdgsdgs来自aaaa变量.
这是我的代码:
request_xml: function()
{
http_request = false;
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
if (!http_request)
{
return false;
}
http_request.onreadystatechange = this.response_xml;
http_request.open('GET', realXmlUrl, true);
http_request.send(null);
xmlDoc = http_request.responseXML;
},
response_xml:function ()
{
if (http_request.readyState == 4)
{
if(http_request.status == 404 && countXmlUrl<=3)
{
countXmlUrl++;
realXmlUrl = xmlUrl[countXmlUrl];
this.request_xml();
}
if (http_request.status == 200)
{
xmlDoc = http_request.responseXML;
alert("need to update3");
this.peter_save_data();
}
}
},
peter_save_data:function()
{
// removed function code
},
Run Code Online (Sandbox Code Playgroud)
奇怪的是,警报没有问题,但是下面的函数调用给了我这个错误:
Error: this.peter_save_data is not …Run Code Online (Sandbox Code Playgroud) 我的(测试)Chrome扩展程序中有一个非常简单的代码:
function test()
{
alert("In test!");
}
chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
var url = tab.url;
if (url !== undefined) {
test();
}
});
Run Code Online (Sandbox Code Playgroud)
我的问题是,为什么要开test()两次?更重要的是,我如何才能一次点火?
我想尝试连接到远程文件并将输出从那里写入本地文件,这是我的功能:
function get_remote_file_to_cache()
{
$the_site="http://facebook.com";
$curl = curl_init();
$fp = fopen("cache/temp_file.txt", "w");
curl_setopt ($curl, CURLOPT_URL, $the_site);
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec ($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
touch('cache/404_err.txt');
}else
{
touch('cache/'.rand(0, 99999).'--all_good.txt');
}
curl_close ($curl);
}
Run Code Online (Sandbox Code Playgroud)
它在"cache"目录中创建了两个文件,但问题是它没有将数据写入"temp_file.txt",为什么会这样?
谢谢!
[R
在我的一个变量上做一个alert()给了我这个结果
[object NodeList]
Run Code Online (Sandbox Code Playgroud)
我怎样才能看到其中的所有值?
注意; 我在Firefox上,不知道如何使用chromebug,所以它没有安装.