我试图在AppCompatActivity中的ViewPager中的片段中创建ListView.在AppCompatActivity中,所有视图元素都是CoordinatorLayout中的包装.因为我使用了CoordinatorLayout.我必须使用RecylerView我试图遵循developer.android.com的培训 ,但我的应用程序在我的日志后停止.这是我在myFragment中停止应用程序的代码.
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
//...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_city_list, container, false)
mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list);
mLayoutManager = new LinearLayoutManager(this.getActivity());
Log.d("debugMode", "The application stopped after this");
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new RecyclerAdapter(getNames());
mRecyclerView.setAdapter(mAdapter);
return view;
}
//...
Run Code Online (Sandbox Code Playgroud) 我想看看mouseclick是否在矩形区域(在画布中)。在C#中,我会这样做。
var point = new Point(x, y);
var rectangles = new List<Rect>();
//rectangles.add(new Rect(x,y,h,w));
foreach(var rectangle in rectangles)
{
if(rectangle.Contains(point))
{
//do something
}
}
Run Code Online (Sandbox Code Playgroud)
我在Javascript中尝试过
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rect(20,20,150,100);
if (ctx.isPointInPath(20,50))
{
//do something
};
Run Code Online (Sandbox Code Playgroud)
但是上下文中的矩形比我列表矩形中的矩形更多。有人可以帮我吗?
我对cq的linq查询很新.我有一个字符串列表,我想获得一个新列表或删除所有双字符串.
List<string> zipcodes = new List<string>();
zipcodes.Add("1234");
zipcodes.Add("1234");
zipcodes.Add("1234");
zipcodes.Add("4321");
zipcodes.Add("4321");
List<string> groupbyzipcodes =
(from zip in zipcodes
group zip by zip into newgroup
select newgroup.ToList());
Run Code Online (Sandbox Code Playgroud)
无法隐式转换
'System.collection.Generic.IEnumarable<System.Collections.Generic.List<string>'
为'System.collections.Generic.List<string>
.存在显式转换(您是否错过了演员?)
我不得不从前大学工作.所以我运行没有数据库的asp.net解决方案.它创建了一个数据库.我认为这是Code First或Code First Migrations.
然后我在de UI中尝试了一些测试并获得此消息:
EntityFramework.dll中出现"System.NotSupportedException"类型的异常,但未在用户代码中处理
附加信息:无法检查模型兼容性,因为数据库不包含模型元数据.只能检查使用Code First或Code First Migrations创建的数据库的模型兼容性.
这是de消息来自的代码.
public class TemInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<ApplicationDbContext>
{
public override void InitializeDatabase(ApplicationDbContext context)
{
base.InitializeDatabase(context);
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何解决这个或我需要看的地方?
我想在asp.net中保存上传的excel文件.在Chrome中这很好用:
if (Request.Files.Count > 0)
{
var currentUser = User.Identity.GetUserId();
var file = Request.Files[0];
if (file != null && file.ContentLength > 0)
{
var fileName = string.Format(DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss_") + file.FileName);
var path = Path.Combine(Server.MapPath("~/Documents/"), string.Format("{0}", fileName));
file.SaveAs(path);
uploadModel.Document = fileName;
}
}
Run Code Online (Sandbox Code Playgroud)
在Chrome中,var fileName为"2015-06-29 14_33_53_example.xlsx",在IE中,fileName为"2015-06-29 14_21_00_C:\ example.xlsx".并通过执行file.SaveAs(path)抛出错误;
我怎样才能支持IE?
我想将所有 id 插入 sql 表中。以下方法有效,但这需要很长时间。提高速度的最佳或更好的方法是什么?
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
{
string query = "";
foreach (var id in ids) // count = 60000
{
{
query += "INSERT INTO [table] (id) VALUES (" + id + ");";
}
}
SqlCommand command = new SqlCommand(query, connection);
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
reader.Close();
}
connection.Close();
}
Run Code Online (Sandbox Code Playgroud) 您好我是Javascript和NodeJS的新手,但我需要删除列表中带有布尔值的数组中的对象.列表中有3个朋友和2个朋友,isEvil = true;
所以我需要删除2个朋友,输出必须是1.这是我试过的.
我的尝试1:
_.each(user.friends, function(friend) {
if(friend.isEvil){
delete friend;
}
});
console.log(user.friends.length); //output is 3
Run Code Online (Sandbox Code Playgroud)
如果我这样做,它将删除所有属性,但仍然有一个空对象:MyTry 2:
_.each(user.friends, function(friend) {
if(friend.isEvil){
delete f.property1;
delete f.property2;
}
});
console.log(user.friends.length); //output is 3
Run Code Online (Sandbox Code Playgroud)
我尝试的最后一个是:
_.each(user.friends, function(friend, key) {
if(friend.isEvil){
delete user.friends[key];
}
});
console.log(user.friends.length); //output is 3
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用该项目作为 React 中的参数创建一个 listitem 单击侦听器。但是现在在加载页面而不是单击项目时调用函数 itemClick。
itemClick = (item) => {
console.log(item)
}
render(){
return(
<Fragment>
{this.state.list.map(item=> (
<tr onClick={this.itemClick(item)}>
<td>{item.firstname}</td>
<td>{item.lastname}</td>
</tr>
))}
</Fragment>
)
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,该函数将在我点击时被调用,但我无法获得参数
<tr onClick={this.itemClick} >
Run Code Online (Sandbox Code Playgroud)
帮助?
我正在尝试将文件从nodeJS 和express.router 发送到客户端。但我收到这个错误:
...webserver/node_modules/express/lib/response.js:412 如果(完成)返回完成(错误);^
TypeError:done 不是 SendStream.ondirectory 的 /home/alex/project/webserver/node_modules/express/lib/response.js:412:22 处的函数(/home/pthong/project/webserver/node_modules/express/lib/ response.js:986:5)在emitNone(events.js:67:13)在SendStream.emit(events.js:166:7)在SendStream.redirect(/home/alex/project/webserver/node_modules/express/ node_modules/send/index.js:401:10) 在 onstat (/home/alex/project/webserver/node_modules/express/node_modules/send/index.js:622:41) 在 FSReqWrap.oncomplete (fs.js:82) :15)
这是我的代码:
router.get('/getFile/:filename', function(req,res){
res.sendFile(__dirname, '../uploads', req.params.filename);
});
Run Code Online (Sandbox Code Playgroud)
http请求是: http: //dummy.com/getFile/audio-461074839300.3gpp
——如果我尝试这个:
res.sendFile('/uploads/'+ req.params.filename);
Run Code Online (Sandbox Code Playgroud)
我收到下一个错误:
错误:ENOENT:没有这样的文件或目录,错误时出现 stat '/uploads/audiomessage-10207974875988003-1327917607235274-1461074839300.3gpp'
这是网络服务器的结构:webs