程序设计

专业和发烧友程序员的问答

12
将数据发送回Android中的主活动
我有两个活动:主要活动和儿童活动。 当我在主要活动中按一个按钮时,子活动将启动。 现在,我想将一些数据发送回主屏幕。我使用了Bundle类,但是没有用。它引发一些运行时异常。 有什么解决办法吗?

5
.NET NewtonSoft JSON反序列化映射到其他属性名称
我有以下从外部方收到的JSON字符串。 { "team":[ { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"home", "score":"22", "team_id":"500" } }, { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"away", "score":"30", "team_id":"600" } } ] } 我的映射类: public class Attributes { public string eighty_min_score { get; set; } public string home_or_away { get; set; } public string score { get; set; } public …



5
用成员函数启动线程
我正在尝试std::thread使用不带参数和返回值的成员函数构造一个void。我无法找出任何有效的语法-编译器会抱怨。什么是正确的实现方式spawn(),使其返回std::thread执行结果test()? #include <thread> class blub { void test() { } public: std::thread spawn() { return { test }; } };

9
PHP + MySQL交易示例
我真的还没有找到使用MySQL事务的PHP文件的正常示例。你能给我简单的例子吗? 还有一个问题。我已经做了很多编程工作,并且没有使用事务。我可以放置PHP函数或其他东西吗?header.php如果其中一个mysql_query失败了,那么其他人也失败了? 我想我已经知道了,对吗?: mysql_query("SET AUTOCOMMIT=0"); mysql_query("START TRANSACTION"); $a1 = mysql_query("INSERT INTO rarara (l_id) VALUES('1')"); $a2 = mysql_query("INSERT INTO rarara (l_id) VALUES('2')"); if ($a1 and $a2) { mysql_query("COMMIT"); } else { mysql_query("ROLLBACK"); }
294 php  mysql  transactions 





13
为什么需要设置原型构造函数?
在MDN文章“面向对象的Java语言简介”中有关继承的部分中,我注意到它们设置了prototype.constructor: // correct the constructor pointer because it points to Person Student.prototype.constructor = Student; 这有任何重要目的吗?可以省略吗?

30
使用Laravel Eloquent获取最后插入的ID
我目前正在使用以下代码在表中插入数据: <?php public function saveDetailsCompany() { $post = Input::All(); $data = new Company; $data->nombre = $post['name']; $data->direccion = $post['address']; $data->telefono = $post['phone']; $data->email = $post['email']; $data->giro = $post['type']; $data->fecha_registro = date("Y-m-d H:i:s"); $data->fecha_modificacion = date("Y-m-d H:i:s"); if ($data->save()) { return Response::json(array('success' => true), 200); } } 我想返回插入的最后一个ID,但我不知道如何获取它。 亲切的问候!

15
Android共享的用于创建一次性活动的偏好设置(示例)[关闭]
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,使其成为Stack Overflow 的主题。 3年前关闭。 改善这个问题 我有三个活动A,B和C,其中A和B是表单,并且在将表单数据填充并保存到数据库(SQLITE)中之后。我正在使用从A到B然后从B到C的意图。我想要的是每次打开应用程序时都希望C作为主屏幕,而不再是A和B. 我想可以通过共享首选项来解决这个问题,但是我找不到一个很好的例子来说明我的出发点。任何帮助,将不胜感激。

12
如何在Android中暂停/休眠线程或进程?
我想在两行代码之间暂停一下,让我解释一下: ->用户单击一个按钮(实际上是卡片),然后通过更改此按钮的背景来显示它: thisbutton.setBackgroundResource(R.drawable.icon); ->假设1秒钟之后,我需要通过更改其背景回到按钮的先前状态: thisbutton.setBackgroundResource(R.drawable.defaultcard); ->我尝试使用以下命令在这两行代码之间暂停线程: try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } 但是,这不起作用。也许是过程而不是我需要暂停的线程? 我也尝试过(但是不起作用): new Reminder(5); 有了这个: public class Reminder { Timer timer; public Reminder(int seconds) { timer = new Timer(); timer.schedule(new RemindTask(), seconds*1000); } class RemindTask extends TimerTask { public …

8
如何将收藏转换为列表?
我正在TreeBidiMap从Apache Collections库中使用。我想对这些值进行排序doubles。 我的方法是Collection使用以下方法检索一个值: Collection coll = themap.values(); 这自然工作正常。 主要问题:现在,我想知道如何将/转换(不确定哪个是正确的)coll转换为一个,List以便可以对其进行排序? 然后,我打算遍历已排序的List对象,该对象应该是有序的,并使用迭代器将位于的列表上的位置从TreeBidiMap(themap)获取适当的键。themap.getKey(iterator.next())doubles

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.