我正在EditText
设置以下属性,以便在用户单击EditText时可以在键盘上显示完成按钮.
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
Run Code Online (Sandbox Code Playgroud)
当用户点击屏幕键盘上的完成按钮(完成输入)时,我想更改RadioButton
状态.
如何从屏幕键盘上点击完成按钮?
最后一次Windows更新打破了整个构建链,我对它的原因有点不知所措.
我有一个遗留项目,这是一个带有大量项目的VS 2017解决方案(winform,基于Web,仅限一些Webapi).
当地的事情很完美.我可以建立它们.
在服务器上,proejct已经开始失败,错误是:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project …
Run Code Online (Sandbox Code Playgroud) 这些功能的根本区别是什么?我所知道的全部三个结果都是201,这适用于成功的POST请求.
我只关注我在网上看到的例子,但他们并没有真正解释为什么他们正在做他们正在做的事情.
我们应该为我们的GET提供一个名称(id为1条记录):
[HttpGet("{id}", Name="MyStuff")]
public async Task<IActionResult> GetAsync(int id)
{
return new ObjectResult(new MyStuff(id));
}
Run Code Online (Sandbox Code Playgroud)
命名此get函数的目的是什么,除了它可能是以下POST函数所需的"可能":
[HttpPost]
public async Task<IActionResult> PostAsync([FromBody]MyStuff myStuff)
{
// actual insertion code left out
return CreatedAtRoute("MyStuff", new { id = myStuff.Id }, myStuff);
}
Run Code Online (Sandbox Code Playgroud)
我注意到CreatedAtRoute
还有一个不包含路由名称的重载.
还有一个CreatedAtAction
类似的参数.为什么存在这种变体?
还有Created
一个期望URL和我们想要返回的对象.我可以使用这个变体并提供一个伪造的URL并返回我想要的对象并完成它并完成吗?
我不确定为什么有这么多的变种只是为了能够将201返回给客户端.在大多数情况下,我想要做的就是返回"app-assigned"(很可能来自数据库)唯一ID或具有最少信息的我的实体版本.
我认为最终,201响应"应该"创建一个位置标题,其中包含新创建的资源的URL,我相信所有3和它们的重载最终会完成.为什么我总是要返回一个位置标题?我的JavaScript客户端,本机移动和桌面应用程序从不使用它.例如,如果我发出HTTP POST来创建账单并将其发送给用户,这样的位置URL会是什么?(我很抱歉没有深入研究互联网的历史,为此寻找答案.)
为什么要为动作和路线创建名称?动作名称和路线名称之间有什么区别?
我对此感到困惑,所以我使用了Ok()
返回200,这不适合POST.
我正在尝试动态调整我的textview,但getlinecount()方法总是在settext()和invalidate()之后返回0.我正在使用以下代码:
if (convertView == null) {
convertView = lInflater.inflate(R.layout.listview, null);
holder = new ViewHolder();
holder.text2 = (TextView)convertView.findViewById(R.id.TextView02);
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
holder.text2.setText(arr2[position]);
holder.text2.invalidate();
int lineCnt = holder.text2.getLineCount();
Run Code Online (Sandbox Code Playgroud)
holder是一个静态类,如下所示:
static class ViewHolder {
TextView text2;
}
Run Code Online (Sandbox Code Playgroud)
holder包含非null text2,内容集也为非null.
有人可以帮忙吗?
Thanx提前.
这是我的Hub
代码:
public class Pusher : Hub, IPusher
{
readonly IHubContext _hubContext = GlobalHost.ConnectionManager.GetHubContext<Pusher>();
public virtual Task PushToOtherInGroup(dynamic group, dynamic data)
{
return _hubContext.Clients.Group(group).GetData(data);
}
}
Run Code Online (Sandbox Code Playgroud)
我想用这段代码在另一个项目中调用此方法:
var pusher = new Pusher.Pusher();
pusher.PushToOtherInGroup("Test", new {exchangeTypeId, price});
Run Code Online (Sandbox Code Playgroud)
我想要调用PushToOtherInGroup
,在调用方法时我没有得到任何错误.但是推送器不起作用.
这是我的Ui代码:
$(function() {
hub = $.connection.pusher;
$.connection.hub.start()
.done(function() {
hub.server.subscribe('newPrice');
console.log('Now connected, connection ID=' + $.connection.hub.id);
})
.fail(function() { console.log('Could not Connect!'); });
});
(function() {
hub.client.GetData = function (data) {
debugger;
};
});
Run Code Online (Sandbox Code Playgroud)
我的问题是什么?
我知道SetupSet是在Moq中设置属性的旧方法.现在它是obsolette但是我的intellisense显示两者都没有标记为Obsolette.谁能指出我们之间的实际区别?
我正在尝试使用该语句动态添加xaml资源文件,
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("resources/leaf_styles.xaml", UriKind.Relative) });
Run Code Online (Sandbox Code Playgroud)
这是抛出异常,无法找到资源'resources/leaf_styles.xaml'.
我将leaf_styles.xaml文件添加到资源文件夹下的项目中,BuildAction设置为"Content",CopyAlways设置为True.我仍然得到这个错误.有人可以帮我指出什么错?
附加信息 -
如果我把它作为绝对位置,它正常工作.
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(@"D:\foo\trunk\bin\resources\leaf_styles.xaml", UriKind.Absolute) });
Run Code Online (Sandbox Code Playgroud) 我的两个朋友已经测试了我一直在研究的项目,该项目依赖于WebBrowser控件的使用,并且设法遇到WebBrowser控件无法在包含的网页上执行任何JavaScript的常量场景.
为了缩小范围,我创建了一个仅包含WebBrowser控件的新Windows窗体项目,并尝试导航到以下页面:http://javatester.org/javascript.html
朋友电脑上的结果如下(点击放大):
正如您所看到的,在尝试调用JS特定代码时,它不会呈现任何内容,或者如果您在禁用或启用了JS的Web浏览器中查看它,您将会看到一些内容.
他导出了包含启用JavaScript设置的注册表项(请参阅https://gist.github.com/4699943),每个键中1400的值与我使用的相同设置匹配,当我运行程序时我没有问题.
整个测试项目的代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Shown(object sender, EventArgs e)
{
this.webBrowser1.Navigate("http://javatester.org/javascript.html");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果使用此代码创建一个新项目,该代码面向4.5框架(在我的机器上或他的机器上),它可以工作,但是如果使用4.0或更低版本创建一个,则会出现上述结果.我不确定这是巧合,还是确实与问题/解决方案有关.
应该注意的是,如果他在Internet Explorer中导航到此页面没有问题,它会检测到JavaScript已启用,此问题仅存在于此测试应用程序及其所属的主项目中.
任何帮助将不胜感激,我花了两个月的时间试图解决这个问题,但仍然不能.
让我们假设我有两个项目。
第一个是依赖于其日志记录的ASP.NET Core MVC 项目NLog.Extensions.Logging
。这很棒; 我可以在我的控制器上使用依赖注入来获取一个ILogger
实例,并且该nlog.config
文件包含我的 NLog 配置。
第二个是 API 所依赖的类库,它直接依赖NLog
于其日志记录。它包含这样的调用:
public class SampleClass
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public void DoStuff()
{
if (_failed) Logger.Error("oh no");
}
}
Run Code Online (Sandbox Code Playgroud)
这些类是用一些自反魔法实例化的,我不能使用依赖注入来替换它们的记录器。您也可以将它们视为某种模型,无法在启动时实例化。
如何让我的库日志显示在 API 的日志输出中?我希望他们会被nlog.config
自动抓住,但他们似乎没有。
我使用 aTileService
作为快捷方式来打开我的应用程序的Activity
. 它只做那个,没有状态。
它看起来像这样:
class QuickAccessTileService : TileService() {
override fun onClick() {
super.onClick()
val intent = Intent(this, SlideOverActivity::class.java)
.addFlags(FLAG_ACTIVITY_NEW_TASK)
startActivityAndCollapse(intent)
}
}
Run Code Online (Sandbox Code Playgroud)
它声明AndroidManifest
为:
class QuickAccessTileService : TileService() {
override fun onClick() {
super.onClick()
val intent = Intent(this, SlideOverActivity::class.java)
.addFlags(FLAG_ACTIVITY_NEW_TASK)
startActivityAndCollapse(intent)
}
}
Run Code Online (Sandbox Code Playgroud)
就目前而言,这是有效的。但是,当我的应用程序停止时,下次我尝试通过快速设置面板打开它时,需要几秒钟才能启动该活动。
这是我所知道的:
Activity 本身启动起来并不慢。尝试通过启动器打开它会很清楚。
本Service
似乎是什么服用一段时间才能开始之前,onClick
甚至执行。这说得通; Service
当应用程序没有运行时,它可能不会在后台运行。然而,这意味着,当系统检测到我的点击Tile
,将Service
首先必须重建,这需要的时间太长了。
我不知道从哪里开始——如果我的猜测是对的。
编辑:作为一个重要的补充,我可以在运行 Android Pie 的 OnePlus 7 Pro …
我有一个.txt文件,其中包含以下内容:
1 1111 47
2 2222 92
3 3333 81
Run Code Online (Sandbox Code Playgroud)
我想逐行阅读并将每个单词存储到不同的变量中.
例如:当我读到第一行"1 1111 47"时,我希望将第一个单词"1"存储到var_1
"1111"中var_2
,并将"47"存入var_3
.然后,当它到下一行,该值应该存储到同一个var_1
,var_2
并var_3
分别变量.
我最初的方法如下:
import java.io.*;
class ReadFromFile
{
public static void main(String[] args) throws IOException
{
int i;
FileInputStream fin;
try
{
fin = new FileInputStream(args[0]);
}
catch(FileNotFoundException fex)
{
System.out.println("File not found");
return;
}
do
{
i = fin.read();
if(i != -1)
System.out.print((char) i);
} while(i != -1);
fin.close();
}
}
Run Code Online (Sandbox Code Playgroud)
请给我你的建议.谢谢
如何重写代码以在 Chrome 自定义选项卡上打开链接:
imageView5 = (AppCompatImageView) findViewById(R.id.image_view5);
imageView5.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view3) {
Intent intent1 =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://mekotube.com/muslim/"));
((HOMEActivity) getContext()).startActivity(intent1);
}
});
Run Code Online (Sandbox Code Playgroud) c# ×5
android ×4
.net ×2
asp.net-core ×2
.net-core ×1
file-io ×1
http-post ×1
ime ×1
java ×1
javascript ×1
mocking ×1
moq ×1
nlog ×1
signalr ×1
signalr-hub ×1
textview ×1
unit-testing ×1
visual-studio-2017-build-tools ×1
wpf ×1
xaml ×1