ListView ls=(ListView)findViewById(**R.id.list**);
ls.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
AlertDialog.Builder adb=new AlertDialog.Builder(ListAllTracks.this);
adb.setTitle("LVSelectedItemExample");
// adb.setMessage("Selected Item is = "+String.valueOf(ls.getItemIdAtPosition(position)));
adb.setPositiveButton("Ok", null);
adb.show();
}
});
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 当我将文件上传到我的FTP(zip或gif)文件时,我有一个非常奇怪的问题.
我正在创建一个包含代码的zip文件,并将其上传代码到FTP.当我在本地磁盘上创建它时,我可以打开任何这种文件类型.但是,当我上传任何这个到FTP而不是下载时,它会向我显示.zip文件的消息为"意外的归档结束",并且在我下载它们并尝试在XP中打开Windows图片和传真查看器后为.gif文件类型"绘图失败":
我使用此代码上传到FTP:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.tim.com/" + fileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential(ftpuser,ftppass);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(filePath +"\\"+ fileName);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
request.KeepAlive = false;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
Run Code Online (Sandbox Code Playgroud) private void hour()
{
Toast.makeText(this,String.valueOf(Calendar.HOUR_OF_DAY),Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud) 我对 Cake PHP 删除 javascript 确认对话框有问题。
我正在使用这段代码:
<td><?php echo $this->Html->link('Delete',
array('controller' => 'RealEstate', 'action' => 'delete',$r['RealEstate']['id']),
array('onclick'=>'return confirm(\"Are you sure?\");'))?> </td>
Run Code Online (Sandbox Code Playgroud)
这会产生 html:
<td><a onclick='return confirm(\"Are you sure?\");' href="/cake1/RealEstate/delete/65">Delete</a> </td>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,这会产生错误的 Html。
如何解决这个问题?
已修复:问题出在反斜杠“你确定吗?”,只需删除 \,这效果很好“你确定吗?”
我有关于在Php Storm中结束foreach行的问题(cake php 2.4.6)
这是我在ctp文件中的代码:
<h2>List Users</h2>
<table>
<tr>
<td>Name:</td>
<td>Password:</td>
</tr>
<?php foreach ($users as $user); ?>
<tr>
<td><?php echo $this->$user['User']['username'];?> </td>
<td><?php echo $this->$user['User']['password'];?></td>
</tr>
<?php endforeach ?>
</table>
Run Code Online (Sandbox Code Playgroud)
在这一行我有错误:
<?php endforeach ?>
Run Code Online (Sandbox Code Playgroud)
(期待声明)
这有什么问题?
我有问题productName参数,其中包含字符串Acreditors buye's something,在这种情况下,我只需要检查db中是否存在productname和SKU.
我收到了错误
's'附近的语法不正确.
字符串''后面的未闭合引号.
我尝试了一些逃避字符的东西,也使用了类似但没有作品.
这是我的代码:
String query = "SELECT * FROM " + toDB + ".dbo.Products WHERE Name like '" + productName.Replace("'","\'") + "' and SKU='" + newSKU+"'";
SqlConnection c = new SqlConnection(cs);
SqlCommand command = new SqlCommand(query, c);
c.Open();
object o = (object)command.ExecuteScalar();
c.Close();
Run Code Online (Sandbox Code Playgroud)
这只是我对SQL注入感到惊讶的样本
非常感谢您帮助我:这是实际上工作的代码:
string commandText = "SELECT * FROM " + toDB + ".dbo.Product WHERE Name= @prodName and SKU=@sku;";
using (SqlConnection c = new SqlConnection(cs))
{
SqlCommand command = …Run Code Online (Sandbox Code Playgroud) android ×2
c# ×2
cakephp ×2
calendar ×1
confirmation ×1
dropdown ×1
field ×1
ftp ×1
javascript ×1
listview ×1
parameters ×1
php ×1
phpstorm ×1
rails-admin ×1
ruby ×1
sql ×1
sql-server ×1
time ×1