使用VisualRefresh设置时,如何使用Google地图的"新"默认图标?
默认图标为:http://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-poi.png&scale=1
以前的地址如下所示:http://maps.google.com/mapfiles/marker_green.png,但在同一地图中使用新旧图标效果不佳.
我想使用JNI从C返回一个字符串数组到Java.我看到我可以用NewObjectArray()这种方式:
JNIEXPORT jobjectArray JNICALL Java_Array_initStringArray(JNIEnv *env, jclass cls, jint size)
{
jclass stringCls = (*env)->FindClass(env, "Ljava/lang/String;");
if (stringCls == NULL) return NULL;
jstringArray result = (*env)->NewObjectArray(env, size, StringCls, NULL);
if (result == NULL) return NULL;
...
}
Run Code Online (Sandbox Code Playgroud)
但是在这里,我不知道int size参数:我不知道我将用于填充数组的字符串数量.那么有没有办法在不事先知道数组大小的情况下创建jobjectArray?
有点像创建一个空数组,然后逐个添加jobject到该数组?
编辑:使用ArrayList的解决方案,如Edwin建议的那样
jclass arrayClass = (*jenv)->FindClass(jenv, "java/util/ArrayList");
if (arrayClass == NULL) return NULL;
jmethodID mid_init = (*jenv)->GetMethodID(jenv, arrayClass, "<init>", "()V");
if (mid_init == NULL) return NULL;
jobject objArr = (*jenv)->NewObject(jenv, arrayClass, mid_init));
if (objArr == NULL) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将结构作为指针从JNI传递到Java,以便稍后可以将其从Java传递回JNI.我已经读过这个帖子:通过JNI在C和Java之间传递指针,但是我没有成功.
我有一个非常复杂的结构: struct myStruct_s myStruct;
从Java,我称之为JNI函数初始化结构,并返回一个长(指针结构):
JNIEXPORT jlong JNICALL Java_example_ExampleJNI_getStruct(JNIEnv *jenv, jclass jcls) {
struct myStruct_s mystruct;
long *lp = (long*)&myStruct;
return lp;
}
Run Code Online (Sandbox Code Playgroud)
然后我用一个长的参数调用一个Java方法.在JNI中,我希望能够使用之前创建的strcuture.我喜欢这个:
JNIEEXPORT jint JNICALL Java_example_ExampleJNI_methode1(JNIEnv *jenv, jclass jcls, jlong jarg) {
struct myStruct_s *arg = (struct myStruct_s *)&jarg;
...
}
Run Code Online (Sandbox Code Playgroud)
好吧它不起作用.我想我对结构中的长镜头是错误的.我该怎么办?谢谢.
编辑:感谢您的提示,这里是工作函数
JNIEXPORT jint JNICALL Java_example_ExampleJNI_methode1(JNIEnv *jenv, jclass jcls, jlong jarg) {
struct myStruct_s *arg;
arg = (struct myStruct_s *)jarg;
...
}
JNIEXPORT jlong JNICALL Java_example_ExampleJNI_getStruct(JNIEnv *jenv, jclass jcls) {
struct myStruct_s *myStruct; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Android NDK 和 Cmake 来生成我的项目的共享库。
我正在将现有项目从 Ubuntu 移植到 Android,现在我需要移植一些可执行文件。我成功编译了所有需要Threads库的可执行文件 sexecpt 。
在 CMakeList.txt 中,FIND_PACKAGE(Threads)可以在为 Ubuntu 编译时找到该库,但不适用于 Android。
我跟着这个cmake 和 libpthread但没有成功。
我想我应该写这个FindThread.cmake文件,但我对 CMake 还很陌生,我真的不知道该怎么做,尤其是因为我不知道 Android 的线程库在哪里。
任何帮助,将不胜感激。谢谢
我正在使用JQuery mobile和Google Map API.除非我刷新页面并且我不明白原因,否则地图无法正确显示.
这是我的map.html文件:
<div data-role="page" id="map-page">
<div data-role="content" id="canvas-map" style="background-color:red"></div>
<script src="js/map.js"></script>
<script type="text/javascript">
var $canvasMap = $('#canvas-map');
$('#canvas-map').on('pagebeforeshow', initMap());
</script>
</div>
Run Code Online (Sandbox Code Playgroud)
和我的map.js文件:
function initMap() {
"use strict";
google.maps.visualRefresh = true;
var marker, map,
myLocation = {lat:50, lon:-80},
mapOptions = {
zoom: 5,
center: new google.maps.LatLng(myLocation.lat, myLocation.lon),
mapTypeId: google.maps.MapTypeId.PLAN,
disableDefaultUI: true
};
$('#canvas-map').css("height", "200px").css("padding", "0px");
map = new google.maps.Map(document.getElementById('canvas-map'), mapOptions);
/** MyPosition **/
marker = new google.maps.Marker({
map: map,
draggable: false,
animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(myLocation.lat, myLocation.lon),
}); …Run Code Online (Sandbox Code Playgroud) javascript jquery google-maps google-maps-api-3 jquery-mobile
是否可以指定NSMutableArray只能包含某种类型的对象.例如,如果我只想存储这种对象:
@interface MyObject : NSObject {
UInt8 value;
}
Run Code Online (Sandbox Code Playgroud)
为了能够像这样使用实例变量:
- (void)myMethod:(NSMutableArray *)myArray{
for (id myObject in myArray){
[self otherMethod:myObject.value];
}
}
Run Code Online (Sandbox Code Playgroud)
因为我收到了这个错误:
request for member 'value' in something not a structure or union
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助
我在iPhone编程中的UITextView中显示数据时遇到了困难.
我正在分析传入的音频数据(来自麦克风).为了做到这一点,我从SignalAnalyzer类创建了一个对象"analyzer",它执行传入数据的分析.我想要做的是实时显示TextView中的每个新传入数据.
因此,当我按下按钮时,我创建了分析传入数据的对象"分析器".每次有新数据时,我都需要在TextView中将它显示在屏幕上.
我的问题是我收到错误,因为(我认为)我正在尝试向父类发送消息(在我的UITextView中显示内容的那个:它有一个在Interface Builder中链接的UITexView实例变量) .我该怎么做才能告诉我的父班需要显示什么?或者我应该如何设计我的课程以自动显示?
谢谢您的帮助.
PS:这是我的错误:
2010-04-19 14:59:39.360 MyApp[1421:5003] void WebThreadLockFromAnyThread(),
0x14a890: Obtaining the web lock from a thread other than the main thread
or the web thread. UIKit should not be called from a secondary thread.
2010-04-19 14:59:39.369 MyApp[1421:5003] bool _WebTryThreadLock(bool),
0x14a890: Tried to obtain the web lock from a thread other than the main thread
or the web thread. This may be a result of calling to UIKit from a secondary thread.
Crashing now...
Program received …Run Code Online (Sandbox Code Playgroud) 我正在创建这样的日期:
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY"];
NSInteger year = [[dateFormatter stringFromDate:[NSDate date]] intValue];
NSLog(@"NSInteger YEAR : %d\n", year);
//minutes, hours, day and month are initialized elsewhere...
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setYear:year];
[comps setMonth:month];
[comps setDay:day];
[comps setHour:hours];
[comps setMinute:minutes];
NSDate *sampleDate = [gregorian dateFromComponents:comps];
NSLog(@"sampleDate YEAR : %d\n", [[dateFormatter stringFromDate:sampleDate] intValue]);
Run Code Online (Sandbox Code Playgroud)
我的问题是,当日期是1月1日或1月2日,这一年是不正确的..这应该是2010年(因为我今天检索),但实际上是2009年......我不明白为什么!这只发生在那两天......
你知道为什么会这样吗?先感谢您.
objective-c ×3
c ×2
google-maps ×2
iphone ×2
android ×1
android-ndk ×1
arrays ×1
cmake ×1
java ×1
javascript ×1
jquery ×1
nscalendar ×1
nsdate ×1
pointers ×1
pthreads ×1
struct ×1
uitextview ×1
xcode ×1