【发布时间】:2024-01-16 11:21:01
【问题描述】:
我有一个窗口,可以在标签中显示我的推文。
我的推文来自我的 FB 页面状态,如果我放了一张图片或写了超过 140 个字符,那么我会在推文中获得一个指向实际帖子的链接。
我想知道是否有任何方法可以拆分标签文本,以便我可以将链接指向要在 webview 中打开的 url
这是我已经走了多远:
var win = Ti.UI.currentWindow;
win.showNavBar();
var desc = Ti.UI.createLabel({
text: win.data,
font:{
fontSize:'20dp',
fontWeight:'bold'
},
height:'300dp',
left:'5dp',
top:'10dp',
color:'#111',
touchEnabled:true
});
win.add(desc);
desc.addEventListener('click',function(e){
var v = desc.text;
if(v.indexOf('http') != -1){
// open new window with webview
var tubeWindow = Ti.UI.createWindow({
modal: true,
barColor: '#050505',
backgroundColor: '#050505'
});
var linkview = Ti.UI.createWebView({
url: e.v,
barColor: '#050505',
backgroundColor: '#050505'
});
// Create a button to close the modal window
var close_modal = Titanium.UI.createButton({title:'Stäng'});
tubeWindow.rightNavButton = close_modal;
// Handle close_modal event
close_modal.addEventListener('click', function() {
tubeWindow.close();
});
tubeWindow.add(linkview);
tubeWindow.open({
modalTransitionStyle: Ti.UI.iPhone.MODAL_TRANSITION_STYLE_FLIP_HORIZONTAL,
});
}
});
win.open();
我被告知我需要拆分 win.data 以获取链接。 (win.data 是推文)
现在我只有:url: e.v,我需要把链接拿出来
关于它如何工作的任何想法?
感谢
//R
【问题讨论】:
-
我的回答有帮助吗?如果是这样,其他人可能对此感兴趣,请投票/标记最佳答案或添加评论说明有什么问题,以便其他人可以从中受益
标签: java text split label appcelerator-mobile