有没有人有关于如何在Ionic 2/Angular 2项目中使用Cordova Native File Plugin的完整示例?
我安装了这个插件,但文档似乎对我来说没有多大意义,因为它是碎片化的,缺乏一个完整的例子,包括所有需要的导入.
例如,以下示例不显示LocalFileSystem或窗口等对象的来源.
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
console.log('file system open: ' + fs.name);
fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) {
console.log("fileEntry is file?" + fileEntry.isFile.toString());
// fileEntry.name == 'someFile.txt'
// fileEntry.fullPath == '/someFile.txt'
writeFile(fileEntry, null);
}, onErrorCreateFile);
}, onErrorLoadFs);
Run Code Online (Sandbox Code Playgroud)
例如,我需要创建一个属性文件.首先,我需要检查应用程序沙箱存储区域中是否存在文件,如果不存在,我必须创建它.然后我必须打开文件写入数据并保存.我怎么能这样做?
我正在为Android开发一个应用程序.
我怎么能在ExpandableListView组中放一个按钮?
单击该按钮将显示一个对话框,而不是打开或关闭该组.单击按钮外部,组应该正常打开和关闭.
下图显示了我要插入按钮的位置.
http://img193.imageshack.us/img193/2060/expandablelistviewbutto.png
我需要使用新语法向Javascript类添加方法.我试过这种方式:
class X{
constructor() {
this.a = 'b'
}
x(){
}
}
X.prototype.y = function (){
console.log('y')
}
var x = new X()
x.y()
console.log(X) // print the the class but not the new method.
Run Code Online (Sandbox Code Playgroud)
它只是打印:
class X{
constructor() {
this.a = 'b'
}
x(){}
}
Run Code Online (Sandbox Code Playgroud)
但我期待
class X{
constructor() {
this.a = 'b'
}
x(){}
y(){
console.log('y');
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Javascript类中添加新方法?
我正在尝试使用ORMLite预填充Android SQLite数据库.问题是这个操作太慢了.这需要几分钟.下面的代码显示了它是如何发生的.
RuntimeExceptionDao<Company, Integer> companyDao = ORMLiteHelper.getInstance(context).getCompanyRuntimeDao();AssetManager am = context.getAssets();
try {
InputStream instream = am.open("companies.sqlite");
if (instream != null) {
InputStreamReader inputreader = new InputStreamReader(instream);
BufferedReader buffreader = new BufferedReader(inputreader);
String line;
try {
while ((line = buffreader.readLine()) != null) {
//Log.i("SQL", line);
if (line.startsWith("INSERT INTO Companies")) {
companyDao.executeRaw(line);
}
}
} catch (Exception e) {
Log.i("SQL", e.getMessage() + " " + e.getLocalizedMessage());
}
}
} catch (Exception e) {
Log.i("SQL", e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
companies.sqlite是一个包含数千行插入的文件,如下所示:
INSERT INTO Companies (id, name) …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,我正在使用API级别8.但是我希望这个应用程序在Froyo和Gingerbread上运行时会使用ICS的主题,因为ICS的主题更加美观.我希望至少按钮的颜色方案和形状是相同的.有没有办法做到这一点?
android themes styles android-2.2-froyo android-4.0-ice-cream-sandwich
我正在开发一个Angular 2应用程序,它必须在可滚动表中显示大量数据.
数据在我的组件类中的数组中:
export class AppComponent {
clients: any[] = [];
constructor(){
for (var i = 0; i < 10; ++i) {
this.clients.push({
id: i,
name: 'Client' + i,
address: 'Address of client ' + i,
phone: '(51) 5454-4646'
});
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我的布局中通过ngFor加载数据:
<div style="height:600px;overflow:scroll">
<data-table>
<th>Id</th>
<th>Name</th>
<th>Address</th>
<th numeric>Phone</th>
<tr *ngFor="let client of clients">
<td>{{ client.id }}</td>
<td>{{ client.name }}</td>
<td>{{ client.address }}</td>
<td>{{ client.phone}}</td>
</tr>
</data-table>
</div>
Run Code Online (Sandbox Code Playgroud)
例如,它必须在包含10.000,可能,20.000行和大约10列的表中加载数据.这里的问题是加载速度非常慢,加载后运行时间很长.
在这种情况下我不能使用分页,并且滚动是强制性的.我想保持滚动拇指的大小和位置,好像所有数据都被加载,即使我需要做一些技巧,如加载部分数据.
我想知道在没有减速的情况下完成这项任务的最佳方法是什么.
android ×3
angular ×3
typescript ×3
android-4.0-ice-cream-sandwich ×1
bulkinsert ×1
button ×1
class ×1
css ×1
ecmascript-5 ×1
events ×1
file ×1
html ×1
html-table ×1
ionic2 ×1
javascript ×1
methods ×1
ormlite ×1
performance ×1
prototype ×1
scrollbar ×1
styles ×1
themes ×1