所以我用leafet.js制作这个应用程序.这个应用程序要求我必须手动将网格绘制到屏幕上,我已经注意了一个draw_grid()将一堆多边形绘制到屏幕上的功能.
我有这个函数,我打电话来触发传单地图的更改.
zoom- 缩放整数,size是一个像{x:1,y:1}控制绘制到地图上的瓷砖大小的字典.(他们需要改变,因为在下面绘制瓷砖的单位是地图上的纬度,长点.
function changeZoom(zoom,size){
map.setZoom(zoom);
setSize(size);
setTimeout(drawGrid,500)s;
Run Code Online (Sandbox Code Playgroud)
}
我必须使用setTimeout的原因是因为传单ignores任何绘图命令到地图上(我正在做一个图层),直到地图完成动画.
如何异步执行此操作?
我有一个列表适配器,我正在尝试为(item.xml)设置自定义xml,如果我不使用通胀(通过应用程序上下文直接识别textview),它工作得很好..但是我的listview不能是主题..
public View getView(int position, View convertView, ViewGroup parent) {
//System.gc();
TextView tv;
LayoutInflater inflater = getLayoutInflater();
View row = View.inflate(mContext,R.layout.item,null); //.inflate(R.layout.item, parent, false); doesnt work either..
String id = null;
if (convertView == null) {
tv = (TextView) row.findViewById(R.id.TextView01);;
} else
tv = (TextView) convertView;
Run Code Online (Sandbox Code Playgroud)
[..]
在logcat我得到这个..
07-15 19:45:51.710: ERROR/AndroidRuntime(20185): FATAL EXCEPTION: main
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
at android.widget.ListView.setupChild(ListView.java:1827)
at android.widget.ListView.makeAndAddView(ListView.java:1794)
at android.widget.ListView.fillDown(ListView.java:688)
Run Code Online (Sandbox Code Playgroud)
我的item.xml文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="fill_parent"
android:paddingBottom="15px"
android:background="#fff200" …Run Code Online (Sandbox Code Playgroud) 我有这个正则表达式来从 python 代码库中删除所有打印语句:
for f in $(find . -name '*.py') ;
do
egrep -v '^[ \t]print ' $f > $f.new
mv $f.new $f
done
Run Code Online (Sandbox Code Playgroud)
但它真的不起作用..
find . -name '*.py' | xargs egrep '^[ \t]*print'
Run Code Online (Sandbox Code Playgroud)
仍然从我的代码中打印出打印语句..:(
但是,我想修改它以注释掉其中包含 print 语句的所有行(这样它们就不会完全从代码库中消失)。
我怎样才能有效地做到这一点?更好的是有一种自动化的方法将所有内容转换为日志框架吗?
因此,我需要在OSX上注册一个函数(使用Xcode/objective C),该函数将在程序终止时注册要调用的特定函数.
我碰到了这个,但我猜这是适用于iOS而不适用于OSX.
我用NS替换了UI并给了它一个镜头,但它没有用.
NSApplication *app = [NSApplication sharedApplication];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillTerminate:)
name:BeCalledOnExit object:app];
Run Code Online (Sandbox Code Playgroud)
但这不是编译.它在名称上说了一些东西:当它在函数之前明显位于.h和.m文件时,是一个未声明的标识符.
我遇到另一个用过这个的小伙子:
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender{
return TRUE
}
Run Code Online (Sandbox Code Playgroud)
但它不适合我,因为我的应用程序是一个完整的状态栏应用程序.
基本上我在我的应用程序中创建一些临时文件,在退出之前,我想确保我的应用程序正在清除这些文件.我把它放在/ tmp/..不想要太多空间.
我真的想要一个像gcc/python这样的解决方案,
atexit(functionName);
Run Code Online (Sandbox Code Playgroud) android ×1
asynchronous ×1
cocoa ×1
comments ×1
django ×1
javascript ×1
leaflet ×1
logging ×1
macos ×1
objective-c ×1
python ×1
regex ×1