Posts

Android : selectors for custom listviews -

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@drawable/layout_bg1" /> <!-- focused --> <item android:state_pressed="true" android:drawable="@drawable/layout_bg1" /> <!-- pressed --> <item android:drawable="@drawable/layout_bg" /> <!-- default --> </selector> i trying use custom drawables in list selector.here error message getting in first line: the processing instruction target matching "[xx][mm][ll]" not allowed. you try codes dependable need . such as <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/footer_color" android:state_pressed="true...

dropdownbox - how to set selected dropdown list in html -

this code dropdown list,plz guide me. <div class = "form-inline"> <label class = "">situation</label> <select selected="" name="sit" id="situ" class='form-control'style="margin-left: 30px; width: 145px;"> <option value="" >select</option> <? if ($situation != '') { $revise = $situation; } foreach ($revise $row): ?> <option value="<?= $row['id']; ?>"><?= $row['situation']; ?></option> <? endforeach; ?> </select> </div> for item want selected dropdown list, add attribute selected . eg. <select> <option value="0">0</option> <option value="1" selected="selected">1</option> <option value="2">2</option> </select> in case, 1 selected. to value ...

php - Update Cart count with AJAX success - WordPress -

in custom wordpress theme, placed cart icon in header.php , other things placed in <li class="user-cart"> . placed db query within <li> , "add cart" button i'm trying reload <li> can query again , show updated count of products added. on ajax success can using: success: function (data) { $('.user-cart').load(window.location.href + ' .user-cart'); } when i'm clicking on add cart button, it's reloading <li> update count() , it's taking <li> within parent <li> , like: <li class="user-cart"> <li class="user-cart"> <a href="/view-cart"><span class="user-cart-icon"></span>&nbsp;15</a> </li> <!-- cloned li --> </li> <!-- parent or original li --> but part that, cloned <li> loads once, on first click after page reload, count comes within second <li> . what...

serialization - Create a Gson TypeAdapter for a Guava Range -

i trying serialize guava range objects json using gson, default serialization fails, , i'm unsure how correctly implement typeadapter generic type. gson gson = new gson(); range<integer> range = range.closed(10, 20); string json = gson.tojson(range); system.out.println(json); range<integer> range2 = gson.fromjson(json, new typetoken<range<integer>>(){}.gettype()); system.out.println(range2); assertequals(range2, range); this fails so: {"lowerbound":{"endpoint":10},"upperbound":{"endpoint":20}} passed: typetokeninterface failed: range java.lang.runtimeexception: unable invoke no-args constructor com.google.common.collect.cut<java.lang.integer>. register instancecreator gson type may fix problem. @ com.google.gson.internal.constructorconstructor$12.construct( constructorconstructor.java:210) ... note default serialization loses information - ...

python - How do I name a function that takes an object `A` and a set `{A, B}` as arguments, then returns `B`? -

what name following function (as implemented in python)? def a_function(element, a_set): if a_set[0] == element: return a_set[1] if a_set[1] == element: return a_set[0] assert 'a' == a_function('b', ['a', 'b']) i use different function name, different argument names , docstring make clear what's going on, like: def get_other(current, both): """return element 'both' not 'current'.""" ... note both implies pair without long-winded, , doesn't specify type required. you can use own implementation or joel's; long function says, doesn't matter how it's implemented (barring performance concerns, edge cases, etc.). however, work non-indexable containers (like set , or keys of dict ) without having explicitly test both is, go for: def get_other(current, both): """return element 'both' not 'current'....

java - Method in inner class stripped away by proguard -

i'm working on android project, in i'm doing calculation in c, using android ndk. my application works fine long not run proguard, when do, method "reportprogress", stripped away proguard. method part of private inner class extends asynctask private class calculatetask extends asynctask i call native code reference calculatetask instance. native code call member in class, using following code in jni jclass taskclass = (*env)->getobjectclass(env, task); jmethodid reportprogressmid = (*env)->getmethodid(env, taskclass, "reportprogress", "(ljava/lang/string;i)z"); where task reference instance of calculatetask. i'm having hard time telling proguard not strip away public boolean reportprogress(string, int) method, called via jni. until have taken following approaches, none of did trick: keeping entire class: -keep class mypackagename.calculatescreen$calculatetask only keeping mentioned method, doing: -keep class my...

java - Magnetic sensor and image rotation in Android -

trying build magnetic compass, have following code. public void onsensorchanged(sensorevent event) { imagecompass = (imageview) findviewbyid(r.id.imagemapdrawview); bitmap myimg = bitmapfactory.decoderesource(getresources(), r.drawable.compass); matrix matrix = new matrix(); matrix.postrotate(event.values[0] ); bitmap rotated = bitmap.createbitmap(myimg, 0, 0, myimg.getwidth(), myimg.getheight(), matrix, true); imagecompass.setimagebitmap(rotated); } i have following questions, a. guess event.values[0] in degree? not in radian? b. want image image view , rotate around center of image, telling that? c. want draw image (an indicator on top of image), can this? have compass image in image view , want draw image on top. can't redraw whole view. how can achieve it? a. check http://developer.android.com/reference/android/hardware/sensorevent.html . the length , contents of values array depends on sensor type being monitored. sens...