特征检测(Feature detection)
我不确定是否有Android方法可以做到这一点,或者这只是一个普通的Java问题。 功能检测机制的最佳设计是什么? 我希望能够询问运行时环境是否支持功能foo(这可能在编译时确定,因此不仅仅是运行时的东西)。
UPDATE
我正在考虑使用以下(天真的?)方法:
public enum Feautures { GPS, DockToKeyboard; public boolean isSupported() { //switch statement } }
I'm not sure if there is an Android way to do this or if this is just a general Java question. What is the best design for a feature detection mechanism? I want to be able to ask if the runtime environment supports feature foo (this may be determined at compile time as well, so not just runtime stuff).
UPDATE
I'm thinking of using the following (naive?) approach:
public enum Feautures { GPS, DockToKeyboard; public boolean isSupported() { //switch statement } }
原文:https://stackoverflow.com/questions/5985380
更新时间:2023-09-23 18:09
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
使用来自React的键盘事件 - http://facebook.github.io/react/docs/events.html例如: var CommentForm = React.createClass({ handleSubmit: function(e) { alert("YES again"); return; }, handleKeyPress: function(e){console.log(e.which);if(e.which == 13){this.hand ...
-
将您的js代码更改为 $(function () { $("[name='Hello']").change(function () { alert($(this).val()); if ($(this).val() != "") { $("form").submit(); } }); }) function ClickMe() { $(".Hello").click(); } 在这里查看演示 Change you ...
-
请注意您使用的是: $('#errorMsg').innerHTML("Emails need to be the same!"); 如果你试图提醒$('#errorMsg').innerHTML它将是未定义的。 当你使用JQuery选择器$('#errorMsg') JQuery将使用拥有JQuery特殊方法(val,html等)的JQuery dom对象包装dom对象,因此你无法访问核心方法innerHTML ,而是你应该使用: $('#errorMsg').html("Emails need to ...
-
.submit()没有在表单上触发(.submit() not firing on form)[2021-09-23]
问题是.spin()没有定义。 尝试删除包含.spin()并尝试提交表单。 $('form#loginForm').submit(function(event) { // Get data and submit $.getJSON("lib/class/class.login.php", {loginUser: $('input#loginUser').val(), loginPassword: $('input#loginPassword').val(), queryType: "1"}) ... -
我设法弄清楚我做错了什么并让它运转起来! 1)OnSubmit函数应该接收参数e,2)触发器的创建应该在初始化函数中,并且3)我使用了不正确的表单ID(没有意识到表单编辑和视图ID不同!) I managed to figure out what I did wrong and got it working! 1) The OnSubmit Functions should receive an argument e, 2) The creation of the triggers should be in ...
-
如有必要,可以使用getWrappedInstance获取包装组件实例: this.refs.form.getWrappedInstance().submit() You can get the wrapped component instance, if necessary, with getWrappedInstance: this.refs.form.getWrappedInstance().submit()
-
可能有更简单的选项,但您可以停止提交按钮,然后在下一帧提交表单(使用setTimeout): 比如像 $('input[type=submit]').click(function(e){ var $form = $(this).closest('form'); e.preventDefault(): setTimeout(function(){ $form.submit(); }, 0); }); 问题是如何允许Enter键表单提交工作,如果您在按Enter ...
-
只需在表单元素上使用事件.triggerHandler('submit')。 myApp.directive("extSubmit", ['$timeout',function($timeout){ return { link: function($scope, $el, $attr) { $scope.$on('makeSubmit', function(event, data){ if(data.formName === $at ...