java - split method for text value in Appcelerator -
i have window displays tweets in label.
my tweets come fb page statuses , if have put pic or write more 140 characters link in tweet actuall post.
i wonder if there way label text split can point link url open in webview
this how far have got:
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 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 button close 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(); what i´ve been told need split win.data link. (win.data tweet)
now have: url: e.v, need link out
any ideas on how can work?
thanx
//r
i did similar thing while ago. pull down tweet(s) run text through regular expression pull out url.
what did put each tweet in tableview row, , set tableview row haschild=true if regular expression returned anything, onclick of tableview row, if haschild == true open webview given url (stored in row).
a regualr expression 1 here should work: http://www.geekzilla.co.uk/view2d3b0109-c1b2-4b4e-bffd-e8088cbc85fd.htm
so like:
str= <<tweet text>>; re= <<url expression>>; check=str.match(re); now check contains either null or url.
Comments
Post a Comment