我有一个自定义对话框,当我尝试获取EditText的值时,它返回null.
该行返回null
EditText et = (EditText)findViewById(R.id.username_edit);
Run Code Online (Sandbox Code Playgroud)
这是完整的代码.
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_TEXT_ENTRY:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
return new AlertDialog.Builder(TicTacToe.this)
//.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(getTitleText())
.setView(textEntryView)
.setPositiveButton("JOIN GAME", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
try
{
EditText et = (EditText)findViewById(R.id.username_edit);
playerName = et.getText().toString();
}
catch (Exception e)
{
}
}
})
.create();
}
return null;
}
Run Code Online (Sandbox Code Playgroud) 做某事之间是否有区别?
SELECT *
FROM table1 INNER JOIN table2 ON table2.ObjectId = table1.table2ObjectId
WHERE table2.Value = 'Foo'
Run Code Online (Sandbox Code Playgroud)
VS
SELECT *
FROM table1 INNER JOIN table2
ON table2.ObjectId = table1.table2ObjectId AND table2.Value = 'Foo'
Run Code Online (Sandbox Code Playgroud) 我有2个阵列.我想将第一个数组的索引转换为第二个数组.有没有比我下面更好的方法呢?
Array array1[9];
Array array2[3][3];
// Index is the index of the 1D array
public Point convert1Dto2D(int index)
{
Point p = new Point();
switch (index) {
case 0:
p.x = 0;
p.y = 0;
break;
case 1:
p.x = 0;
p.y = 1;
break;
case 2:
p.x = 0;
p.y = 2;
break;
case 3:
p.x = 1;
p.y = 0;
break;
case 4:
p.x = 1;
p.y = 1;
break;
case 5:
p.x = 1;
p.y = 2; …
Run Code Online (Sandbox Code Playgroud) 如何在不传递上一级的情况下在C++中找到递归函数内的当前深度?即,是否可以知道调用函数的次数而不使用参数来跟踪级别并在每次调用函数时将该数字作为参数传递?
例如,我的递归函数如下所示:
DoSomething(int level)
{
print level;
if (level > 10)
return;
DoSomething(++level);
}
main
{
DoSomething(0);
}
Run Code Online (Sandbox Code Playgroud) 在Flutter中,当流的值更改时如何调用Navigator.push?我已经尝试了下面的代码,但出现错误。
StreamBuilder(
stream: bloc.streamValue,
builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
if (snapshot.hasData && snapshot.data == 1) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SomeNewScreen()),
);
}
return Text("");
});
Run Code Online (Sandbox Code Playgroud)
如何在javascript中设置锚标记的文本?这似乎不起作用.我正在使用Firefox.
var link = document.createElement("a");
link.innerHtml = "Remove";
Run Code Online (Sandbox Code Playgroud) 如何编写脚本以从此站点下载文件.是否可以通过URL提供登录名和密码?
http://feeds.itunes.apple.com/feeds/epf/
我会像这样格式化网址吗?
WebClient Client = new WebClient();
Client.DownloadFile("http://feeds.itunes.apple.com/feeds/epf/v3/full/current/itunes20110511.tbz.md5?username=myusername&password=mypassword", @"C:\folder\file.md5");
Run Code Online (Sandbox Code Playgroud) 我有一个使用jQuery和AJAX调用服务器端脚本来创建一个文本文件,并返回以下响应按钮:
Response.ContentType = "csv";
Response.AddHeader("Content-disposition", "attachment; filename=" + fName);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
Run Code Online (Sandbox Code Playgroud)
但是,不会出现保存对话框.如果我不使用Ajax和使用相同的代码执行完整的回发,它的工作原理.有任何想法吗?
这是jQuery代码:
$(function() {
$('#reportButton').click(function() {
$.ajax({
type: "POST",
url: "GenerateReport.aspx",
data: "id=0",
success: function(){
}
});
});
});
Run Code Online (Sandbox Code Playgroud) 特定 searchString = "23423asdfa-''"
这个正则表达式应该评估为false,但它不会!有任何想法吗?
Regex rgx = new Regex(@"[\w-]*");
rgx.IsMatch(searchString)
Run Code Online (Sandbox Code Playgroud) 假设我有一张名为 assets 的表,其中包含以下字段:
id | job_id | title
Run Code Online (Sandbox Code Playgroud)
我想使用 id 和 job_id 作为主键。job_id 是外键。id 字段是自动递增的。如果没有具有相同 job_id 的行,我如何让 id 从 0 开始递增。如果存在具有相同 job_id 的行,则将 id 增加 1,依此类推?
我正在寻找的结果是一个看起来像这样的表:
id | job_id | title
0 1 hi
1 1 hello
2 1 goodbye
0 2 hi
1 2 hello
Run Code Online (Sandbox Code Playgroud)
现在假设添加了一个 job_id = 3 的新行。id 字段应该再次从 0 开始自动递增。