当前位置: 编程技术>移动开发
本页文章导读:
▪ListView_HS 兑现水平+垂直双向滚动 ListView_HS 实现水平+垂直双向滚动
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
.........
▪ ListView_Syncpic 以异步模式加载图片 ListView_Syncpic 以异步形式加载图片
ListView形式预览图片:以异步形式加载图片
......
▪ [转]封存数据的一系列方法 [转]保存数据的一系列方法
保存数据的一系列方法
http://cocoachina.com/bbs/read.php?tid-9414-fpage-0-toread--page-1.html
/*=======================================================
NSKeyedArchiver
========================.........
[1]ListView_HS 兑现水平+垂直双向滚动
来源: 互联网 发布时间: 2014-02-18
ListView_HS 实现水平+垂直双向滚动
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:scrollbars="horizontal" > <LinearLayout android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/layouthead" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffCded8b" > <TextView android:id="@+id/item1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="编号" android:width="50dip" /> <TextView android:id="@+id/item2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="账目" android:text android:width="100dip" /> <TextView android:id="@+id/item3" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="费用(元)" android:textSize="14dip" android:text android:width="100dip" /> <TextView android:id="@+id/item4" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="日期" android:textSize="14dip" android:text android:width="150dip" /> <TextView android:id="@+id/item5" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="备注" android:textSize="14dip" android:text android:width="100dip" /> </LinearLayout> <ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="150dp" android:scrollbars="vertical" > </ListView> </LinearLayout> </HorizontalScrollView> </ScrollView> </LinearLayout>
[2] ListView_Syncpic 以异步模式加载图片
来源: 互联网 发布时间: 2014-02-18
ListView_Syncpic 以异步形式加载图片
ListView形式预览图片:以异步形式加载图片
[3] [转]封存数据的一系列方法
来源: 互联网 发布时间: 2014-02-18
[转]保存数据的一系列方法
保存数据的一系列方法
http://cocoachina.com/bbs/read.php?tid-9414-fpage-0-toread--page-1.html /*======================================================= NSKeyedArchiver ========================================================*/ NSString * str = @"abc" ; NSString * astr = @"efg" ; NSArray * Array = [ NSArray arrayWithObjects : str, astr, nil ] ; //Save NSString * Path = [ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) objectAtIndex : 0 ] ; NSString * filename = [ PathstringByAppendingPathComponent : @"test" ] ; [ NSKeyedArchiver archiveRootObject : Array toFile : filename ] ; str = @"a" ; astr = @"" ; //load NSArray * arr = [ NSKeyedUnarchiver unarchiveObjectWithFile : filename ] ; str = [ arr objectAtIndex : 0 ] ; astr = [ arr objectAtIndex : 1 ] ; NSLog ( @"str:%@" ,str) ; NSLog ( @"astr:%@" ,astr) ; /*======================================================= NSUserDefaults ========================================================*/ NSString * str = @"abc" ; NSString * astr = @"efg" ; NSArray * Array = [ NSArray arrayWithObjects : str, astr, nil ] ; //Save NSUserDefaults * SaveDefaults = [ NSUserDefaults standardUserDefaults ] ; [ SaveDefaults setObject : Array forKey : @"SaveKey" ] ; str = @"a" ; astr = @"" ; //load Array = [ SaveDefaults objectForKey : @"SaveKey" ] ; str = [ Array objectAtIndex : 0 ] ; astr = [ Array objectAtIndex : 1 ] ; NSLog ( @"str:%@" ,str) ; NSLog ( @"astr:%@" ,astr) ; /*======================================================= writeToFile: ========================================================*/ NSString * str = @"abc" ; NSString * astr = @"efg" ; NSArray * Array = [ NSArray arrayWithObjects : str, astr, nil ] ; //Save NSArray * paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) ; NSString * documentsDirectory = [ paths objectAtIndex : 0 ] ; if ( ! documentsDirectory) { NSLog ( @"Documents directory not found!" ) ; } NSString * appFile = [ documentsDirectory stringByAppendingPathComponent :@"Savedatas.plist" ] ; [ [ NSArray arrayWithObjects : Array ,nil ] writeToFile : appFile atomically : NO ] ; //load if ( [ [ NSFileManager defaultManager ] fileExistsAtPath : appFile] ) self .SaveDataArray = [ NSMutableArray arrayWithContentsOfFile : appFile] ; else self .SaveDataArray = [ NSMutableArray arrayWithContentsOfFile : [ [ NSBundlemainBundle ] pathForResource : @"Savedatas" ofType : @"plist" ] ] ; NSArray * strArray = [ self .SaveDataArray objectAtIndex : 0 ] ; str = [ strArray objectAtIndex : 0 ] ; astr = [ strArray objectAtIndex : 1 ] ; //坛子里的,搬过来。。。。。 - ( BOOL ) writeApplicationData: ( NSDictionary * ) data writeFileName: ( NSString * )fileName { NSArray * paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) ; NSString * documentsDirectory = [ paths objectAtIndex : 0 ] ; if ( ! documentsDirectory) { NSLog ( @"Documents directory not found!" ) ; return NO ; } NSString * appFile = [ documentsDirectory stringByAppendingPathComponent : fileName ]; return ( [ data writeToFile : appFile atomically : YES ] ) ; } - ( id ) readApplicationData: ( NSString * ) fileName { NSArray * paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory, NSUserDomainMask, YES ) ; NSString * documentsDirectory = [ paths objectAtIndex : 0 ] ; NSString * appFile = [ documentsDirectory stringByAppendingPathComponent : fileName ]; NSDictionary * myData = [ [ [ NSDictionary alloc ] initWithContentsOfFile : appFile]autorelease ] ; return myData; }
最新技术文章: