程序设计

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

10
如何在线性布局的一侧绘制边框?
我能够将边框绘制为线性布局,但它的四面都被绘制了。我只想将其限制在右侧,就像在CSS中一样(border-right:1px纯红色;)。 我已经尝试过了,但是它仍然可以吸引所有方面: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <stroke android:height="2dp" android:width="2dp" android:color="#FF0000" /> <solid android:color="#000000" /> <padding android:bottom="0dp" android:left="0dp" android:right="1dp" android:top="0dp" /> <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="5dp" android:radius="1dp" android:topLeftRadius="5dp" android:topRightRadius="0dp" /> </shape> </item> 关于如何做到这一点的任何建议? 顺便说一句,我不想​​使用将宽度为1dp的视图放在所需侧面的技巧。
185 android 

19
Android SDK的快速位图模糊
目前,在我正在开发的Android应用程序中,我正在遍历图像的像素以使其模糊。在640x480的图片上,这大约需要30秒。 在Android Market中浏览应用程序时,我碰到了一个包含模糊功能的应用程序,它们的模糊速度非常快(例如5秒),因此它们必须使用另一种模糊方法。 除了遍历像素之外,有人知道更快的方法吗?

30
.NET中每个文件规则一个类?[关闭]
已关闭。这个问题是基于观点的。它当前不接受答案。 想改善这个问题吗?更新问题,以便通过编辑此帖子以事实和引文回答。 3个月前关闭。 改善这个问题 我遵循此规则,但我的一些同事不同意该规则,并争辩说,如果一个班级较小,则可以将其与其他班级放在同一文件中。 我一直听到的另一个论点是:“即使Microsoft也不这样做,那为什么还要这么做?” 对此有什么普遍共识?在某些情况下应避免这种情况?
185 c#  .net 

14
ASP.NET捆绑包如何禁用缩小
我都debug="true"在我的web.config(s)中,但我只是不想缩小我的捆绑包,但是我似乎没有做任何事情来禁用它。我试过了enableoptimisations=false,这是我的代码: //Javascript bundles.Add(new ScriptBundle("~/bundles/MainJS") .Include("~/Scripts/regular/lib/mvc/jquery.validate.unobtrusive.js*") .Include("~/Scripts/regular/lib/mvc/jquery.validate*") .Include("~/Scripts/regular/lib/bootstrap.js") .IncludeDirectory("~/Scripts/regular/modules", "*.js", true) .IncludeDirectory("~/Scripts/regular/pages", "*.js", true) .IncludeDirectory("~/Scripts/regular/misc", "*.js", true)); //CSS bundles.Add(new StyleBundle("~/bundles/MainCSS") .Include("~/Content/css/regular/lib/bootstrap.css*") .IncludeDirectory("~/Content/css/regular/modules", "*.css", true) .IncludeDirectory("~/Content/css/regular/pages", "*.css", true))

14
在单元测试中设置HttpContext.Current.Session
我有一个要尝试进行单元测试的Web服务。在服务中,它从HttpContext类似的方法中提取几个值,如下所示: m_password = (string)HttpContext.Current.Session["CustomerId"]; m_userID = (string)HttpContext.Current.Session["CustomerUrl"]; 在单元测试中,我正在使用简单的工作程序请求创建上下文,如下所示: SimpleWorkerRequest request = new SimpleWorkerRequest("", "", "", null, new StringWriter()); HttpContext context = new HttpContext(request); HttpContext.Current = context; 但是,每当我尝试设置 HttpContext.Current.Session HttpContext.Current.Session["CustomerId"] = "customer1"; HttpContext.Current.Session["CustomerUrl"] = "customer1Url"; 我得到的null引用异常HttpContext.Current.Session为null。 有什么办法可以在单元测试中初始化当前会话?

4
带有自定义Android适配器的ArrayIndexOutOfBoundsException,用于ListView中的多个视图
我试图为我的ListView创建自定义适配器,因为列表中的每个项目都可以具有不同的视图(链接,切换或单选组),但是当我尝试运行使用ListView的Activity时收到错误消息,并且该应用程序停止。该应用程序针对Android 1.6平台。 代码: public class MenuListAdapter extends BaseAdapter { private static final String LOG_KEY = MenuListAdapter.class.getSimpleName(); protected List<MenuItem> list; protected Context ctx; protected LayoutInflater inflater; public MenuListAdapter(Context context, List<MenuItem> objects) { this.list = objects; this.ctx = context; this.inflater = (LayoutInflater)this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getView(int position, View convertView, ViewGroup parent) …

12
如何在PHP中修剪数组值的空白
我有如下数组 $fruit = array(' apple ','banana ', ' , ', ' cranberry '); 我想要一个数组,该数组的值在两边都没有空格,但是它可以包含空值,如何在php中做到这一点。输出数组应该像这样 $fruit = array('apple','banana', ',', 'cranberry');
185 php  arrays 

30
无法加载c ++ bson扩展
总节点菜鸟在这里。我一直在尝试设置示例节点应用程序,但是每次我尝试运行时都会弹出以下错误: 节点应用 Failed to load c++ bson extension, using pure JS version events.js:72 throw er; // Unhandled 'error' event ^ Error: failed to connect to [#$%67890 :27017] at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:553:74) at EventEmitter.emit (events.js:106:17) at null.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15) at EventEmitter.emit (events.js:98:17) at Socket.<anonymous> (/home/thejazeto/code/nodejs/authen/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10) at Socket.EventEmitter.emit (events.js:95:17) at net.js:830:16 at process._tickCallback (node.js:415:13)

14
STL或Qt容器?
使用Qt容器的优点和缺点(QMap,QVector在他们的STL等价物,等等)? 我可以看到一个偏爱Qt的原因: Qt容器可以传递到Qt的其他部分。例如,可以使用它们先填充a QVariant,然后填充a QSettings(尽管有一定限制,但仅接受QList和QMap/且QHash其键为字符串)。 还有其他吗? 编辑:假设应用程序已经依赖Qt。
185 c++  qt  stl 

14
.NET中是否存在只读通用词典?
我在只读属性中返回了对字典的引用。如何防止消费者更改我的数据?如果是这样,IList我可以简单地将其退回AsReadOnly。我可以用字典做类似的事情吗? Private _mydictionary As Dictionary(Of String, String) Public ReadOnly Property MyDictionary() As Dictionary(Of String, String) Get Return _mydictionary End Get End Property

9
如何处理ImeOptions的完成按钮单击?
我在一个EditText地方设置以下属性,以便当用户单击EditText时可以在键盘上显示完成按钮。 editText.setImeOptions(EditorInfo.IME_ACTION_DONE); 当用户单击屏幕键盘上的完成按钮(完成输入)时,我想更改RadioButton状态。 从屏幕键盘上击中完成按钮时,我该如何跟踪?

6
与Redis相比,记忆快取是恐龙吗?[关闭]
已关闭。这个问题是基于观点的。它当前不接受答案。 想改善这个问题吗?更新问题,以便通过编辑此帖子以事实和引文回答。 2年前关闭。 改善这个问题 在过去的几周中,我与memcached进行了很多合作,并发现了有关Redis的信息。当我阅读他们的自述文件的这一部分时,我突然感到肠胃温暖,舒适: Redis可以用作类固醇的内存缓存,因为它与内存缓存一样快,但具有更多功能。像memcached一样,Redis还支持为密钥设置超时,以便在给定的时间量过后自动删除该密钥。 听起来很棒。我还发现此页面带有基准测试:http : //www.ruturaj.net/redis-memcached-tokyo-tyrant-mysql-comparison 因此,说真的-内存缓存真的是那种旧的dinousaur,从性能的角度来看,与这个新手Redis相比,它是一个不好的选择吗? 以前我对Redis的了解很少,因此可以解决我的问题!

10
iOS-如何使用Swift快速编程
我正在创建一个使用Facebook SDK来验证用户身份的应用程序。我正在尝试将Facebook逻辑合并到一个单独的类中。这是代码(为简单起见而被剥离): import Foundation class FBManager { class func fbSessionStateChane(fbSession:FBSession!, fbSessionState:FBSessionState, error:NSError?){ //... handling all session states FBRequestConnection.startForMeWithCompletionHandler { (conn: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in println("Logged in user: \n\(result)"); let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) let loggedInView: UserViewController = storyboard.instantiateViewControllerWithIdentifier("loggedInView") as UserViewController loggedInView.result = result; //todo: …
185 ios  iphone  facebook  swift  segue 


8
上下文中的多个软件包:component-scan,spring config
如何在context:component-scanelement的spring-servlet.xml文件中添加多个包? 我努力了 <context:component-scan base-package="z.y.z.service" base-package="x.y.z.controller" /> 和 <context:component-scan base-package="x.y.z.service, x.y.z.controller" /> 和 <context:component-scan base-package="x.y.z.service" /> <context:component-scan base-package="x.y.z.controller" /> 但出现错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [x.y.z.dao.daoservice.LoginDAO] found for dependency:

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.