Posts

java - Retaining the data in the view during activity switch? -

in android app user can enter text in editview , click on button takes him other activity can select contact ... , press button brings him first activity... now problem need pass selected contact first activity , display (which have done using bundle) unable retain entered text in editview... should (but text should retained out passing through the bundle , getting back) thanks :) the text in view component automagically saved os, after soft kill (user changed phone orientation), not after hard kill, user hit button while parent activity in focus. so, unless doing non-standard, such calling onsaveinstancestate without calling super.onsaveinstancestate, data in view state should persist. one solution save text in view component non view instance property before launch child activity, , read value when focus returns parent activity in method onactivityresult. jal edit: android docs activity page has been extensively updated. view state not saved if widget not hav...

Encoding differences between tr (ubuntu) and tr (mac) -

echo – | tr ’ x on mac: correctly prints – on ubuntu 10.10: prints xx� why? for reference, first character 'en dash' (u+2013), second 'right single quotation mark' (u+2019) edit: use perl instead. magic incantation use is: perl -csd -p -mutf8 -e 'tr/a-zÁÉÍÓÚÀÈÌÒÙÄËÏÖÜÂÊÎÔÛÇa-zäëïöüáéíóúàèìòùâèìòùñçßœ/ /cs' it means: except letters think of, replace character space, , squeeze spaces. gnu coreutils tr has issues multi-byte characters - considers them sequence of single byte characters instead. taking account, see on linux "expected": $ echo – | od -t x1 0000000 e2 80 93 0a 0000004 $ echo ’ | od -t x1 0000000 e2 80 99 0a 0000004 $ echo – | tr ’ x | od -t x1 0000000 58 58 93 0a 0000004 edit: for set of utf-8 compatible utilities, might want have @ heirloom toolchest . contains tr implementation apparently has utf-8 support, although have not tested it.

algorithm - semi-random set of subsets -

i'm trying generate semi-random subsets restrictions. here variable descriptions example values: objcount - number of objects (12) visiblecount (aka setsize) - number of objects per set (6) setcount - number of sets (12) objappearances - number of set in object appears = setcount * visiblecount / objcount i need produce given number of sets (setcount) follow these rules: each set collection of objects, no object can in single set more once. furthermore, each object should in same number of sets. if doesn't devide evenly, number sets in object appears can off 1 (some objects in 4 sets, , others in 5). i'll try avoid situation, it's not critical. it's turning out far less trivial thought. me code/psuedocode? solution generalized version helpful too. thanks in advance. edit: visiblecount set size. number of times object appears (objappearances) setcount * visiblecount / objcount edit2: should add want sets random. if sets have sequential o...

asp.net mvc - Route to subdomain -

i have made asp.net mvc 3 application area called blog. want route area subdomain blog.mywebsite.com. how can achieve this? how need define route? have configure dns? currently use default area route. can access blog area @ way. mywebsite.com/blog you require cname entry setting redirect website. hosting provider able out here if not familiar this.

javascript - Printing the JSON data? -

i learning how use javascript wrote simple script prints out public facebook statuses particular keyword. reason, not doing expect do. sample url json found be: http://graph.facebook.com/search?q=beatles right now, not printing results. can spot error in this? <input type="text" id="query" /><button>add</button><br /> <div id="results"> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ var url='http://graph.facebook.com/search?q='; var query; $('button').click(function(){ query=$("#query").val(); $.getjson(url+query,function(json){ $.each(json.data,function(i,feed){ if(feed.type=='status') { $("#results").append('<...

android - Widget size different while testing on local and publishing - same phone -

i have created small widget want 80w x 100h in size. on phone works fine when testing un-signed. publish app , test widget on phone 160w x 200h... my widget background 80w x 100h. my widget provider xml file below <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:updateperiodmillis="10000" android:minwidth="80px" android:minheight="100px" android:initiallayout="@layout/widget"/> widget.xml layout <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget_base" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:orientation="vertical" android:background="@drawable/widget_b...

html - css - how to change image source by its id? -

does know how can control image source css? i need able change image src css. have loop printing < img id=.. > tags, , every id different image. want able set source id style css area. does know how this? that not possible css. however, easy javascript: document.getelementbyid("idofimage").src = "sourceofimage";