问题列表 - 第36266页

关于getView()的问题

任何人都可以解释以下代码的作用吗?

  public View getView(int position, View convertView, ViewGroup parent) {

   // TODO Auto-generated method stub
   View myView = null;
   try {
    myView = convertView;
    if (null == myView) {
     LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

     myView = li.inflate(R.layout.demographic_list_item, null);

    }
    if (mScan_listItems[position] != null) {
     // read the values and attach them.
     TextView tv1 = (TextView) myView
       .findViewById(R.id.DemoGraphicItem_Text);

     tv1.setText(mScan_listItems[position]);

    }

   } catch (Exception e) {
    e.printStackTrace();
   }

   return myView;
  }

 }
Run Code Online (Sandbox Code Playgroud)

android

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

Asp MVC Action链接绝对URL

我有一组显示给特定用户的视图.这些是我从我们的应用程序中的其他视图复制的视图,并稍微更改了它们.

在这些视图中我使用的是Html.Action链接,但是我需要这些来返回绝对URL而不是相对.我知道有额外的参数可以用来获得这种效果,但我不认为它可以改变我所有视图中的所有链接.

理想情况下,我想在一个地方进行更改,并根据需要渲染我的所有链接.当然必须有我可以设置的东西,或者我可以覆盖的功能来实现这一目标.

c# asp.net-mvc

12
推荐指数
2
解决办法
6233
查看次数

Web服务拒绝接收参数并以JSON回复

我正在尝试以json格式从ac#应用程序调用Web服务(.asmx).

当我将请求方法指定为GET时,并且不指定contentType.

(req是HttpWebRequest)

req.Method = "GET";
Run Code Online (Sandbox Code Playgroud)

一切都运作良好,但我得到XML响应.
当我指定内容时类型:

req.ContentType = "application/json; charset=utf-8";  
Run Code Online (Sandbox Code Playgroud)

我明白了

500内部服务器错误.

当我更改请求方法时:

req.Method = "POST";  
Run Code Online (Sandbox Code Playgroud)

我只能调用无参数方法,它能正确返回json,但如果我尝试调用参数的方法,我会再次得到500错误.

网络服务代码:

    [WebMethod(EnableSession =true)]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string SimplestWebService()
    {         
        return "hello";
    }  
Run Code Online (Sandbox Code Playgroud)

并带参数:

    [WebMethod(EnableSession = true)]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string Echo(string aString)
    {       
        return aString;
    }
Run Code Online (Sandbox Code Playgroud)

任何想法将不胜感激.

补充:也许我没有正确编写POST请求(现在我将其发送到标头中,就像GET请求一样).有人可以指导我吗?

添加模式:网站确实标记为脚本:

[ScriptService]
public class MyAPI : System.Web.Services.WebService  
Run Code Online (Sandbox Code Playgroud)

这是我如何构建我的POST请求(我真的倾向于认为这是问题):

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(methodUrl.ToString());
req.Method = "POST";
req.Headers.Add("aString","oren");
req.ContentLength = 0;    
...
req.ContentType = "application/json; charset=utf-8";
req.Accept = "application/json; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net web-services asmx

5
推荐指数
1
解决办法
4606
查看次数

GZipStream和DeflateStream会生成更大的文件

我正在尝试在C#中使用deflate/gzip流,但看起来压缩后的文件比以前更大.

例如,我压缩了900ko的docx文件,但它产生了1.4Mo!

它为我尝试过的每个文件都做到了.

我做错的方式可能是我错了吗?这是我的代码:

  FileStream input = File.OpenRead(Environment.CurrentDirectory + "/file.docx");
  FileStream output = File.OpenWrite(Environment.CurrentDirectory + "/compressedfile.dat");

  GZipStream comp = new GZipStream(output, CompressionMode.Compress);

  while (input.Position != input.Length)
      comp.WriteByte((byte)input.ReadByte());

  input.Close();

  comp.Close(); // automatically call flush at closing
  output.Close();
Run Code Online (Sandbox Code Playgroud)

c# gzipstream deflatestream

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

ASP.NET MVC向最终用户显示操作成功

我见过的大多数ASP.NET MVC示例都描述了用户正在查看对象(或对象集合)然后从该页面移动到显示用户完成的表单的情况.在提交具有良好输入的表单后,用户被重定向回显示对象(或列表)的页面,并且用户可以看到他们的更改成功.

我遇到了每个业务规则都没有视图或列表页面的情况.

在ASP.NET MVC中,这种场景有哪些好的方法?

在使用Classic ASP和ASP.NET的过去,我会处理输入,然后向用户显示成功消息或带有错误的表单 - 所有这些都来自同一页面.这似乎违背了最佳实践(SRP,视图中没有逻辑等).

一种简单的方法是重定向到一个新页面,告诉用户他们的更改是成功的,但随后用户可以随时访问该页面.如果我开始使用逻辑来防止这种情况(即tempdata),那么解决方案就会变得很脏.

我可以重定向到目标网页,但没有确认.也许我可以依赖一个消息系统,当他们返回登录页面时向最终用户显示确认信息?

asp.net-mvc views single-responsibility-principle

6
推荐指数
1
解决办法
2274
查看次数

分析.exe/.dll(Windows PE)文件以获取代码膨胀

假设我有一个包含十几个不同模块的项目,它们生成一个结果DLL,我该如何分析它以便我可以识别每个模块/函数所贡献的实际文件大小?我知道在Release版本中可能无法删除大量信息,但是如果我拥有完整的源代码并且可以执行Debug构建怎么样?

另外,如果在某处定义了大的静态变量,有没有办法可以轻松找到它们?

奖金问题:Linux ELF文件怎么样?

windows performance diagnostics low-level dumpbin

7
推荐指数
1
解决办法
1604
查看次数

单击子项时如何忽略单击事件

所以我有以下场景:

<div id="block">
Sample text.
<a href="#">Anchor link</a>
</div>

<script type="text/javascript">
    $("#block").click(function() { alert('test'); });
</script>
Run Code Online (Sandbox Code Playgroud)

当我点击div内的任何地方时,我都会收到"测试"警报.但是,当我点击"锚点链接"时,我希望防止这种情况发生.我该如何实现呢?

谢谢

jquery

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

Excel Visual Studio设计时适配器加载项错误

我正在尝试使用VSTO打开excel工作簿2003.但我又一次得到错误

"无法创建项目,因为应用程序加载项无法正常运行并且可能已被禁用.要检查Microsoft Office应用程序中的禁用项目,请打开"帮助"菜单,单击"关于Microsoft Office Word"或"关于Microsoft Office Excel",然后单击"关于".单击"禁用项目".如果出现"Word Visual Studio设计时适配器加载项"或"Excel Visual Studio设计时适配器加载项",请选择它并单击"启用".如果没有,请重新安装或修复Visual Studio Tools的安装.办公室."

有人可以帮忙吗?

excel vsto ms-office visual-studio-2008

4
推荐指数
2
解决办法
4893
查看次数

需要在Ruby中将数组拆分为指定大小的子数组

我有一个类似这样的数组:

arr = [4, 5, 6, 7, 8, 4, 45, 11]
Run Code Online (Sandbox Code Playgroud)

我想要一种奇特的方法

sub_arrays = split (arr, 3)
Run Code Online (Sandbox Code Playgroud)

这应该返回以下内容: [[4, 5, 6], [7,8,4], [45,11]]

Note: This question is not a duplicate of "How to chunk an array" The chunk question is asking about processing in batches and this question is about splitting arrays.

ruby arrays

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

Setting a :has_many :through association on a belongs_to association Ruby on Rails

I have three models, each having the following associations:

class Model1 < ActiveRecord::Base
  has_many :model2s
  has_many :model3s
end

class Model2 < ActiveRecord::Base
  belongs_to :model1
  has_many :model3s, :through => :model1  # will this work? is there any way around this?
end

class Model3 < ActiveRecord::Base
  belongs_to :model1
  has_many :model2s, :through => :model1  # will this work? is there any way around this?
end
Run Code Online (Sandbox Code Playgroud)

As you can see in the commented text, I have mentioned what I need.

ruby ruby-on-rails associations has-many-through belongs-to

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