gpt4 book ai didi

javascript - Titanium 中的 Activity 指示器不起作用

转载 作者:行者123 更新时间:2023-11-29 21:52:31 25 4
gpt4 key购买 nike

我想使用 Titanium 在我的屏幕上显示一个 Activity 指示器,但它没有显示任何结果。它没有显示任何进度标志。

这是我的代码:

var actInd = Titanium.UI.createActivityIndicator();

actInd.message = 'Please wait...';
//message will only shows in android.

var self = Ti.UI.createWindow({
title : "About",
navBarHidden : false,
barColor : "#50b849",
backgroundColor : "#2d2d2d",
});
self.add(actInd);
actInd.show();
self.orientationModes = [Titanium.UI.PORTRAIT];

var text = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory + "info.txt").read();

var infoText = Ti.UI.createTextArea({
width : "100%",
height : "100%",
color : "#fff",
backgroundColor : "#2d2d2d",
value : text,
editable : false,
scrollable : false,
font : {
fontWeight : 'bold',
fontSize : 20,
fontFamily : 'Helvetica Neue'
},
textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER,
autoLink : Ti.UI.AUTODETECT_LINK
});

infoText.addEventListener("click", function() {
Ti.Platform.openURL("http://tellusanotherone.org/c2p");
});

var scrollView = Ti.UI.createScrollView({
width : "100%",
height : "100%",
verticalBounce : true,
scrollType : "vertical",
});
scrollView.add(infoText);
self.add(infoText);

return self;

提前致谢。

最佳答案

只需创建文件 (lib/indicator.js) 并在其中添加以下代码

function createIndicatorWindow(args) {
var width = 180,
height = 50;

var args = args || {};
var top = args.top || 140;
var text = args.text || 'Loading ...';

var win = Titanium.UI.createWindow({
height: height,
width: width,
top: top,
borderRadius: 10,
touchEnabled: false,
backgroundColor: '#000',
opacity: 0.6
});

var view = Ti.UI.createView({
width: Ti.UI.SIZE,
height: Ti.UI.FILL,
center: { x: (width/2), y: (height/2) },
layout: 'horizontal'
});

var style;
if (Ti.Platform.name === 'iPhone OS') {
style = Ti.UI.iPhone.ActivityIndicatorStyle.PLAIN;
} else {
style = Ti.UI.ActivityIndicatorStyle.DARK;
}

var activityIndicator = Ti.UI.createActivityIndicator({
style : style,
height : Ti.UI.FILL,
width : 30
});

var label = Titanium.UI.createLabel({
left: 10,
width: Ti.UI.FILL,
height: Ti.UI.FILL,
text: text,
color: '#fff',
font: { fontFamily: 'Helvetica Neue', fontSize: 16, fontWeight: 'bold' }
});

view.add(activityIndicator);
view.add(label);
win.add(view);

function openIndicator() {
win.open();
activityIndicator.show();
}

win.openIndicator = openIndicator;

function closeIndicator() {
activityIndicator.hide();
win.close();
}

win.closeIndicator = closeIndicator;

return win;
}

// Public interface
exports.createIndicatorWindow = createIndicatorWindow

像这样在你的代码中使用

var uie = require('lib/indicator');
var indicator = uie.createIndicatorWindow();

someViewObject.addEventListener('click', function(e) {
indicator.openIndicator();

setTimeout(function() {
// Do the work that takes a while
// and requires an activity indicator
indicator.closeIndicator();
},0);
});

关于javascript - Titanium 中的 Activity 指示器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14073939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com