在我的应用程序中,数据来自互联网,我正在尝试创建一个功能,检查互联网连接是否可用,如果不是,它会提供一个警报信息,没有互联网连接可用.我正在使用以下代码.但它不起作用.
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
if (isOnline())
{
// my code
}
else
{
Hotgames4meActivity1.this.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
try {
AlertDialog alertDialog = new AlertDialog.Builder(Hotgames4meActivity1.this).create();
alertDialog.setTitle("Info");
alertDialog.setMessage("Internet not available, Cross check your internet connectivity and try again");
//alertDialog.setIcon(R.drawable.alerticon);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alertDialog.show();
}
catch(Exception e)
{
//Log.d(Constants.TAG, "Show Dialog: "+e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想得到Ember生成的元素id.
{{#each}}
<div>
<h1>{{MyComponent}}</h1>
</div>
{{/each}}
Run Code Online (Sandbox Code Playgroud)
它呈现如下:
<div id="ember180" class="ember-view">
<h1>My Component here</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要在控制器中获取每个div元素的id.如果我要使用自定义ID,那么如何使用ember视图创建自定义ID.
如何通过控制器内的id识别每个div元素?
我正在寻找一种方法来计算在搜索数据库时我得到的这些JSON字符串中返回的项目数(以PHP为单位).
请原谅我,因为我完全废弃了这一切.
我被告知因为在JSON版本中没有返回计数,就像在这个数据库中的XML一样,我将不得不使用循环来计算结果的数量?
我环顾四周,但似乎没有什么比我想做的更合适......
以下是我得到的字符串示例:
Array (
[0] => stdClass Object (
[score] => 12
[popularity] => 3
[name] => Samantha Dark
[id] => 151019
[biography] => [url] => http://www.themoviedb.org/person/151019
[profile] => Array ( )
[version] => 16
[last_modified_at] => 2011-04-11 17:17:33
)
[1] => stdClass Object (
[score] => 11
[popularity] => 3
[name] => Johnny Dark
[id] => 158737
[biography] => [url] => http://www.themoviedb.org/person/158737
[profile] => Array ( )
[version] => 14
[last_modified_at] => 2011-04-11 17:18:38
)
) …Run Code Online (Sandbox Code Playgroud) 我无法使以下的Laravel代码正常工作.我正在尝试以下代码.这是表列数组:
$cols = array(
'inc' => array('id'),
'str' => array(
'name',
'email',
'password'
),
...
);
Run Code Online (Sandbox Code Playgroud)
这是功能:
private function addCols($tableName, $cols){
foreach ($cols as $k => $type) {
foreach ($cols[$k] as $col) {
if(!Schema::hasColumn($tableName, $col)){
Schema::table($tableName, function($table)
{
// Problem here $k and $col are `Undefined`
}
// Outside here $k and $col have values like `str`, `name`
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我对PHP不太好.
我有通知div.当有人单击其中一个链接时,通知的数量将会更改,之后用户将被重定向到他单击的链接.这是里面的php脚本div.
<?php
while($row = stmt->fetch(PDO::FETCH_OBJ))
{
echo "<p><a href='http://example.com/blog/index.php?t_id=".$t_id."&c_id=".$c_id."'>".$title."</a></p>";
}
?>
Run Code Online (Sandbox Code Playgroud)
我在里面使用以下Jquery div:
<script>
$('p').click(function(event){
event.preventDefault();
$.ajax({
type: "POST",
url: "http://www.example.com/change_notification.php"
})
.done(function( msg ) {
$("#changed_notification_value").text( msg );
var n_url = $('a', this).attr('href');
window.location.href = n_url;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
通知编号成功更改但在尝试重定向时,n_url显示的值未定义.