小编B. *_*non的帖子

OnClickListener()必须覆盖超类方法吗?

使用此代码:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
. . .

Button buttonAuthorizeUsers = (Button) findViewById(R.id.buttonAuthorizeUsers);
    buttonAuthorizeUsers.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent configure = new  Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class);  
            OnDemandAndAutomatic_Activity.this.startActivity(configure); 
        }
      });
Run Code Online (Sandbox Code Playgroud)

我越来越:

new View.OnClickListener(){}类型的onClick(View)方法必须覆盖超类方法

似乎这个问题有时是由Project |引起的 属性| Java编译器设置为1.5.

虽然我实际上我之前遇到过这个问题,并将其改为1.6,不知何故它再次为1.5.

然而,(将其改为1.6)并没有解决问题.在清洁,建造和F11之后,我仍然得到同样的错误信息...... ???

android android-widget android-button

9
推荐指数
1
解决办法
2万
查看次数

为什么我的Grid Tapped事件没有被调用?

确实,我实际上并没有在模拟器中进行攻击 - 因为我的开发机器没有启用触摸功能 - 但我不认为这是问题,因为我在网格中的点击应该触发事件.

这是我的xaml:

<Grid x:Name="grid1" Margin="24,0,0,0" Grid.Row="1" Tapped="Grid_OnTapped">
Run Code Online (Sandbox Code Playgroud)

......和我的代码:

private void Grid_OnTapped(object sender, TappedRoutedEventArgs args)
{
     if (args.OriginalSource.Equals(grid1))
     {
    . . .
Run Code Online (Sandbox Code Playgroud)

我从来没有进入Grid_OnTapped事件.我错过了什么?

c# grid-layout windows-8 winrt-xaml windows-store-apps

9
推荐指数
1
解决办法
3702
查看次数

我应该担心找不到引用的*.js文件; 如果是的话,我该怎么办呢?

我刚刚在VS 2013中打开了我的ASP.NET站点/项目.我注意到(也许他们也在VS 2012中,但我没有注意它),我在Output窗口中得到了这个:

07:20:45.5493: Referenced file 'jquery-1.8.2.js' not found.
07:20:45.5512: Referenced file 'jquery-ui-1.8.24.js' not found.
07:20:45.6332: Referenced file 'knockout-2.2.0.debug.js' not found.
07:22:11.0550: Referenced file 'jquery-1.8.2.js' not found.
07:22:11.0550: Referenced file 'jquery-ui-1.8.24.js' not found.
07:22:11.0570: Referenced file 'knockout-2.2.0.debug.js' not found.
Run Code Online (Sandbox Code Playgroud)

这是真的,我使用CDN引用jQuery,以及比1.8.2更新的版本,所以我不需要对该版本的引用.但是我的项目在哪里说需要呢?我做了一个解决方案范围的搜索,并且唯一的参考(没有双关语意)到_references.js,其中包含:

/// <reference path="jquery-1.8.2.js" />
/// <reference path="jquery-ui-1.8.24.js" />
/// <reference path="jquery.validate.js" />
/// <reference path="jquery.validate.unobtrusive.js" />
/// <reference path="knockout-2.2.0.debug.js" />
/// <reference path="modernizr-2.6.2.js" />
Run Code Online (Sandbox Code Playgroud)

因此输出窗口的投诉以及_references.js中的内容部分重合.那么:_references.js是如何使用的?我应该删除文件的内容吗?从我的Scripts文件夹中删除命名文件,因为它们没有被使用,或者是什么?

asp.net jquery reference visual-studio-2013

9
推荐指数
1
解决办法
7223
查看次数

如何将多个args传递/接收到RESTful Web API GET方法?

采用参数(返回标量值而不是数据集)的GET RESTful方法的常见示例如下所示:

public string Get(int id)
{
    //get and return the value
}
Run Code Online (Sandbox Code Playgroud)

...传递的val通常是一个ID,因此您可以使用它来获取基于该唯一值的标量值.

但是,如果要传递多个值,例如字符串和int,该怎么办?这只是定义一个这样的方法的问题:

public string Get(string someString, int someInt)
{
    //get and return the value
}
Run Code Online (Sandbox Code Playgroud)

......并且这样称呼它:

//const string uri = "http://192.112.183.42:80/api/platypusItems/someString/someInt";, zB:
const string uri = "http://192.112.183.42:80/api/platypusItems/DuckbilledPlatypisAreGuysToo/42";
var webRequest = (HttpWebRequest) WebRequest.Create(uri);
Run Code Online (Sandbox Code Playgroud)

IOW,路由机制是否会发现,由于传递了两个args,它应该使用两个args("约定优于配置")来调用Get()方法,还是需要做更多的事情来适当地路由事物?

c# rest asp.net-4.5 asp.net-web-api asp.net-web-api-routing

9
推荐指数
1
解决办法
4万
查看次数

为什么CastleWindsor的BeginScope超出范围?

我正在尝试将Castle Windsor添加到我的Web API项目中,并且正在关注此帖子,但是在这行代码中遇到编译时错误:

this._scope = container.BeginScope();
Run Code Online (Sandbox Code Playgroud)

...作为" 'Castle.Windsor.IWindsorContainer'不包含'BeginScope'的定义,并且没有扩展方法'BeginScope'接受类型为'Castle.Windsor.IWindsorContainer'的第一个参数'(你是否错过了使用指令或汇编参考?) "

这是整个代码,以便可以在上下文中看到:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Dependencies;
using Castle.Windsor;
using Castle.MicroKernel.Registration;
using System.Web.Http;

namespace PlatypiPieServer
{
    public class WindsorDependencyResolver : IDependencyResolver
    {
        private readonly IWindsorContainer _container;

        public WindsorDependencyResolver(IWindsorContainer container)
        {
            _container = container;
        }

        public IDependencyScope BeginScope()
        {
            return new WindsorDependencyScope(_container);
        }

        public object GetService(Type serviceType)
        {
            if (_container.Kernel.HasComponent(serviceType))
                return this._container.Resolve(serviceType);
            else
                return null;
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return _container.ResolveAll(serviceType).Cast<object>();
        }

        public void …
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection castle-windsor inversion-of-control asp.net-web-api

9
推荐指数
1
解决办法
2671
查看次数

我可以从运行在其上的Web API应用程序将文件写入服务器计算机上的文件夹吗?

我在我的Web API应用程序中使用此代码写入CSV文件:

private void SaveToCSV(InventoryItem invItem, string dbContext)
{
    string csvHeader = "id,pack_size,description,vendor_id,department,subdepartment,unit_cost,unit_list,open_qty,UPC_code,UPC_pack_size,vendor_item,crv_id";

    int dbContextAsInt = 0;
    int.TryParse(dbContext, out dbContextAsInt);
    string csvFilename = string.Format("Platypus{0}.csv", dbContextAsInt);

    string csv = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", invItem.ID,
        invItem.pksize, invItem.Description, invItem.vendor_id, invItem.dept, invItem.subdept, invItem.UnitCost,
        invItem.UnitList, invItem.OpenQty, invItem.UPC, invItem.upc_pack_size, invItem.vendor_item, invItem.crv_id);

    string existingContents;
    using (StreamReader sr = new StreamReader(csvFilename))
    {
        existingContents = sr.ReadToEnd();
    }

    using (StreamWriter writetext = File.AppendText(csvFilename))
    {
        if (!existingContents.Contains(csvHeader))
        {
            writetext.WriteLine(csvHeader);
        }
        writetext.WriteLine(csv);
    }
}
Run Code Online (Sandbox Code Playgroud)

在开发机器上,默认情况下,csv文件保存为"C:\ Program Files(x86)\ IIS Express".为了准备将它部署到最终的休息/工作场所,我需要做些什么来保存文件,例如,到服务器的"Platypi"文件夹 - 什么特别的?我是否必须专门设置某些文件夹柿子才能写入"Platypi".

这只是改变这条线的问题:

string csvFilename = …
Run Code Online (Sandbox Code Playgroud)

c# file-permissions streamwriter file-processing asp.net-web-api

9
推荐指数
1
解决办法
2万
查看次数

如何使用HTMLAgilityPack写出解码后的HTML?

我尝试使用HTMLAgilityPack和DOCX库将HTML写入DOCX文件时取得了部分成功.但是,我插入到.docx文件中的文本包含编码的html,例如:

La ciudad de Los &Aacute;ngeles (California) ha sincronizado su&nbsp;red completa de sem&aacute;foros &mdash;casi&nbsp;4.500&mdash;, que cubre una zona de 1.215&nbsp;kil&oacute;metros cuadrados (469&nbsp;millas cuadradas). Seg&uacute;n el diario
Run Code Online (Sandbox Code Playgroud)

我想要的更像是这样的:

La ciudad de Los Angeles (California) ha sincronizado su red completa de semaforos - casi 4.500 -, que cubre una zona de 1.215 kilometros cuadrados (469 millas
cuadradas). Segun el diario
Run Code Online (Sandbox Code Playgroud)

为了显示一些上下文,这是我正在使用的代码:

private void ParseHTMLAndConvertBackToDOCX()
{
    List<string> sourceText = new List<string>();
    List<string> targetText = new List<string>();
    HtmlAgilityPack.HtmlDocument htmlDocSource = new HtmlAgilityPack.HtmlDocument();
    HtmlAgilityPack.HtmlDocument htmlDocTarget …
Run Code Online (Sandbox Code Playgroud)

html c# decode innertext html-agility-pack

9
推荐指数
2
解决办法
4780
查看次数

我如何解析这个XML(没有得到"根元素丢失"或"序列不包含元素")?

这是这个问题的一个分支为什么在"穿越Rubicon"之后HttpWebRequest主体为val?这回答了(一个障碍是跳过),但是下一个障碍让我兴奋起来.

使用此代码:

public async void PostArgsAndXMLFileAsStr([FromBody] string stringifiedXML, string serialNum, string siteNum)
{
    XDocument doc = XDocument.Parse(await Request.Content.ReadAsStringAsync()); 
Run Code Online (Sandbox Code Playgroud)

...或这个:

XDocument doc = XDocument.Load(await Request.Content.ReadAsStreamAsync());
Run Code Online (Sandbox Code Playgroud)

...这是作为传入的stringifiedXML:

<?xml version=1.0?>
<LocateAndLaunch>
    <Tasks>Some Task</Tasks>
    <Locations>Some Location</Locations>
</LocateAndLaunch>
Run Code Online (Sandbox Code Playgroud)

...我得到异常:" System.Xml.XmlException未被用户代码处理HResult = -2146232000 Message = Root元素丢失. "

使用此代码(相同的stringifiedXML):

XDocument doc = XDocument.Parse(stringifiedXML);
Run Code Online (Sandbox Code Playgroud)

我明白了

System.InvalidOperationException未被用户代码处理HResult = -2146233079 Message = Sequence不包含任何元素Source = System.Core StackTrace:在System.Linq.Enumerable.First [TSource](IEnumerable`1 source)at HandheldServer.Controllers.DeliveryItemsController.d__2 .MoveNext()在c:\ HandheldServer\HandheldServer\Controllers\DeliveryItemsController.cs:第109行InnerException:

IOW,取决于我如何解析传入的字符串,我得到" 根元素丢失 "或" 序列不包含元素 "

Deuce McAlistair MacLean Virginia Weeper是什么?!?不是<LocateAndLaunch>根元素?不是Some TaskSome Location …

c# linq-to-xml frombodyattribute

9
推荐指数
2
解决办法
3万
查看次数

如何在visual Studio 2013中阻止"尝试从状态为TextDocDataAvailable的适配器获取视图"失败?

当我搜索我的解决方案,并且主窗体(frmMain.cs)在搜索结果中时,双击"查找结果"窗格中的行,该窗格应该将我带到frmMain.cs文件,我经常只看到一个空白IDE中的窗口(虽然是灰色,而不是黑色).如果我然后点击那个灰色模糊的虚无,它告诉我,"试图从状态TextDocDataAvailable状态的适配器获取视图"

关闭VS并重新打开它可以暂时解决问题(然后我可以双击frmMain.cs文件并正常查看),但有没有办法阻止这种反叛的发展?

注意:当发生这种情况时,我也可以在解决方案资源管理器中双击frmMain.cs; 这使得表单中的"可视"部分在IDE中可见; 然后我可以右键单击并选择"查看代码",它可以工作.奇怪,虽然......

visual-studio visual-studio-2013

9
推荐指数
2
解决办法
8499
查看次数

Castle Windsor在运行时解决

我一直试图解决这个问题很长一段时间,我仍然没有更聪明.我有以下方法:

public IResult Parse(string[] args)
{
    var argumentOption = new ArgumentOption(_dataModelBinder);
    var boundArgumentOption = argumentOption.Bind(args);

    var bindingResults = boundArgumentOption.Validate(_argumentOptionValidator);

    // AREA OF INTEREST
    if (bindingResults.Any())
    {
        return new ErrorResult();
    }

    return new CreateReportResult(
        _resultActioner
        , boundArgumentOption.OutputFilePath
        , boundArgumentOption.PatientId
        , "database");
}
Run Code Online (Sandbox Code Playgroud)

我遇到麻烦的代码涉及到我正在创建的返回值,理想情况下我想留给温莎城堡处理.那么,我接下来要创建一个抽象工厂:

public interface IResultFactory
{
    IResult Create(int numOfErrors);
} 

public class ResultFactory : IResultFactory
{
    private readonly IWindsorContainer _container;

    public ResultFactory(IWindsorContainer container)
    {
        _container = container;
    }

    public IResult Create(int numOfErrors)
    {
        if (numOfErrors > 0)
        {
            return _container.Resolve<IResult>("ErrorResult"); …
Run Code Online (Sandbox Code Playgroud)

c# castle-windsor

8
推荐指数
1
解决办法
5775
查看次数