当前位置: 编程技术>移动开发
本页文章导读:
▪assert索引下文件的读取 assert目录下文件的读取
普通的打开方式是:
InputStream inputStream = getAssets().open("test.xml");
带文件夹的:
getAssets().open("database/db.db");
在webview中的打开是:webView.loadUrl("file:///android_asset/test/index.h.........
▪ 透过代码创建联系人 通过代码创建联系人
首先,需要导入AddressBook.framework框架,然后在头文件中加入:#import <AddressBook/AddressBook.h>
CFErrorRef error = NULL;
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef.........
▪ Dreamweaver施用技巧 Dreamweaver使用技巧
利用Dreamweaver对HTML、CSS代码进行重新排版设置完毕,最关键的一步:首先打开你想修改格式的 HTML、CSS 文件,然后点击菜单中的“命令”—“应用源格式”
......
[1]assert索引下文件的读取
来源: 互联网 发布时间: 2014-02-18
assert目录下文件的读取
普通的打开方式是:
InputStream inputStream = getAssets().open("test.xml");
带文件夹的:
getAssets().open("database/db.db");
在webview中的打开是:webView.loadUrl("file:///android_asset/test/index.html");
// bs = FileHelp.FileToXML("history.xml", getCon());// 直接读取根目录下的xml文件
bs = FileHelp.FileToXML(getCon().getResources().getAssets().open( "test/datasync.xml"), getCon());// 直接读取xml
public static String FileToXML(String filename, Context context) { InputStream ios = context.getClassLoader() .getResourceAsStream(filename);// 读取XML流 BufferedReader in = new BufferedReader(new InputStreamReader(ios)); StringBuffer buffer = new StringBuffer(); String line = ""; try { while ((line = in.readLine()) != null) { buffer.append(line); } } catch (IOException e1) { e1.printStackTrace(); } return buffer.toString(); } public static String FileToXML(InputStream ios, Context context) { // InputStream ios = context.getClassLoader() // .getResourceAsStream(filename);// 读取XML流 BufferedReader in = new BufferedReader(new InputStreamReader(ios)); StringBuffer buffer = new StringBuffer(); String line = ""; try { while ((line = in.readLine()) != null) { buffer.append(line); } } catch (IOException e1) { e1.printStackTrace(); } return buffer.toString(); }
[2] 透过代码创建联系人
来源: 互联网 发布时间: 2014-02-18
通过代码创建联系人
首先,需要导入AddressBook.framework框架,然后在头文件中加入:#import <AddressBook/AddressBook.h>
CFErrorRef error = NULL; ABAddressBookRef addressBook = ABAddressBookCreate(); ABRecordRef newPerson= ABPersonCreate(); ABRecordSetValue(newPerson, kABPersonFirstNameProperty, @"Eric", &error); ABRecordSetValue(newPerson, kABPersonLastNameProperty, @"Gao", &error); ABRecordSetValue(newPerson, kABPersonJobTitleProperty, @"市场部经理", &error); ABRecordSetValue(newPerson, kABPersonOrganizationProperty, @"移动技术研发", &error); ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multiPhone, @"12345678", kABPersonPhoneMainLabel, NULL); ABRecordSetValue(newPerson, kABPersonPhoneProperty, multiPhone, &error); CFRelease(multiPhone); ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multiEmail, @"别墅", kABHomeLabel, NULL); ABRecordSetValue(newPerson, kABPersonEmailProperty, multiEmail, &error); CFRelease(multiEmail); ABMutableMultiValueRef urlMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(urlMultiValue,@"www.google.cn", kABPersonHomePageLabel, NULL); ABRecordSetValue(newPerson, kABPersonURLProperty, urlMultiValue, &error); CFRelease(urlMultiValue); ABMutableMultiValueRef multiAddress = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType); NSMutableDictionary *addressDictionary = [[NSMutableDictionary alloc] init]; [addressDictionary setObject:@"北京市海淀区中关村" forKey:(NSString *) kABPersonAddressStreetKey]; ABMultiValueAddValueAndLabel(multiAddress, addressDictionary, kABWorkLabel, NULL); ABRecordSetValue(newPerson, kABPersonAddressProperty, multiAddress, &error); CFRelease(multiAddress); UIImage *image = [UIImage imageNamed:@"head.png"]; if (image) { NSData *dataRef = UIImagePNGRepresentation(image); CFDataRef dr = CFDataCreate(NULL, [dataRef bytes], [dataRef length]); ABPersonSetImageData(newPerson, dr, &error); CFRelease(dr); } ABAddressBookAddRecord(addressBook, newPerson, &error); CFRelease(newPerson); ABAddressBookSave(addressBook, &error);
效果图:
[3] Dreamweaver施用技巧
来源: 互联网 发布时间: 2014-02-18
Dreamweaver使用技巧
利用Dreamweaver对HTML、CSS代码进行重新排版
设置完毕,最关键的一步:首先打开你想修改格式的 HTML、CSS 文件,然后点击菜单中的“命令”—“应用源格式”
利用Dreamweaver对HTML、CSS代码进行重新排版
设置完毕,最关键的一步:首先打开你想修改格式的 HTML、CSS 文件,然后点击菜单中的“命令”—“应用源格式”
最新技术文章: