我使用的jQuery.click
处理上拉斐尔图形的鼠标点击事件,同时,我需要处理鼠标drag
事件,鼠标拖动由mousedown
,mouseup
并mousemove
在拉斐尔.
很难区分click
,drag
因为click
还包含mousedown
&mouseup
,如何在Javascript中区分鼠标"点击"和鼠标"拖动"?
如果我有一个数组[1, 2, 3, 5, 2, 8, 9, 2]
,我想检查2
数组中有多少个.在不使用for
循环循环的情况下,在JavaScript中执行此操作的最优雅方法是什么?
例如,我已经定义了一个方向垂直的根线性布局:
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_root"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
<!-- I would like to add content here dynamically.-->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在根线性布局内,我想添加多个子线性布局,每个子线性布局方向都是水平的.有了这些,我最终会得到一个像输出这样的表格.
例如,具有子布局的root,例如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_root"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
<!-- 1st child (1st row)-->
<LinearLayout
...
android:orientation="horizontal">
<TextView .../>
<TextView .../>
<TextView .../>
</LinearLayout>
<!-- 2nd child (2nd row)-->
...
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
由于子线性布局及其内容的数量非常动态,我决定以编程方式将内容添加到根线性布局.
如何以编程方式将第二个布局添加到第一个布局,还可以为每个子设置所有布局属性并在子设备中添加更多其他元素?
我尝试使用以下代码来获取Android应用程序开发中的屏幕宽度和高度:
Display display = getWindowManager().getDefaultDisplay();
int screenWidth = display.getWidth();
int screenHeight = display.getHeight();
Run Code Online (Sandbox Code Playgroud)
但我得到的NullPointerException我的display
,为什么呢?如何获得屏幕宽度和高度呢?
android android-widget android-emulator android-layout android-activity
当我在Android Studio中构建我的Android项目时,我收到消息:
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
和
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Run Code Online (Sandbox Code Playgroud)
我想做消息建议的内容,但是如何做?-Xlint
如上所述,如何配置我的Android工作室重新编译我的项目?(我使用的是Android Studio 3.0.1)
通过使用jquery ajax函数,我可以做类似的事情:
$.ajax({
url: url,
type: 'GET',
async: true,
dataType: 'json',
data: data,
success: function(data) {
//Handle server response here
},
error: function(xhr, status, error){
//Handle failure here
}
});
Run Code Online (Sandbox Code Playgroud)
根据以上代码,我有两个问题要问:
什么时候error
调用jquery.ajax()回调?
如果服务器使用字符串消息" 有错误 " 向我回复json对象怎么办?这意味着请求仍然成功发送,但我得到了服务器响应{message: "There is an error"}
.
我认为无论服务器响应什么字符串值,如果客户端得到服务器的响应,无论如何都会触发jquery.ajax() success
回调.
我想问一下服务器是否特意向我返回一个字符串值为的JSON对象{message: 'There is an error'}
,服务器可以执行某些操作以便可以在jquery.ajax() error
回调而不是success
回调中处理此响应吗?
如果我将图像名称作为变量,如下所示:
var imageName = SERVICE.getImg();
Run Code Online (Sandbox Code Playgroud)
然后,我怎么能得到资源R.drawable.????
,我试过R.drawable[imageName]
,但它失败了.有什么建议?
android android-widget android-ndk android-emulator android-layout
如果我已经定义了一个Activity:
public class DialogActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(dialog_activity.xml);
}
}
Run Code Online (Sandbox Code Playgroud)
我想像对话框一样显示上面的活动,所以在AndroidManifest.xml文件中,我声明这个活动如下:
<activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"/>
Run Code Online (Sandbox Code Playgroud)
此时一切都很好,我DialogActivity
表现为对话.
问题是如何自定义宽度和高度DialogActivity
使其更像一个小对话框?(目前它默认占据大部分屏幕)
----------------------------更新--------------------- -
我定义了一个自定义主题如下:
<style name="myDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:width">100dip</item>
<item name="android:height">100dip</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后,DialogActivity
在AndroidManifest.xml中声明为.
<activity android:name=".DialogActivity" android:theme="@style/myDialog"/>
Run Code Online (Sandbox Code Playgroud)
我DialogActivity
现在甚至占据整个屏幕:(.宽度和高度定义:
<item name="android:width">100dip</item>
Run Code Online (Sandbox Code Playgroud)
在主题上没有任何效果,为什么?
android android-widget android-manifest android-emulator android-layout
我正在开发rails 2.3.2应用程序.
当我输入命令" rails script/server "时
我得到以下输出而不是服务器启动为什么?
rails script/server
Usage:
rails new APP_PATH [options]
Options:
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-G, [--skip-git] # Skip Git ignores and keeps
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-b, [--builder=BUILDER] # Path to a application builder (can be a …
Run Code Online (Sandbox Code Playgroud) 如何检查我的整数是否可以除以3,如下所示:
for(int i=0; i<24; i++){
//here, how to check if "i" can be divided by 3 completely(e.g. 3, 6, 15)?
}
Run Code Online (Sandbox Code Playgroud)