Posts

How to get the image name of the ImageView in Android? -

i have imageview in android . want name of image set in in imageview. how can ? imageview v = (imageview)findviewbyid(r.id.img); //string name = findimagename(v); if( name.equals(a)) { //do } else{ //do } for first of need set tag imageview <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview1" android:background="@drawable/bg1" android:tag="bg1"/> now image name set on imageview doing following, imageview v = (imageview)findviewbyid(r.id.img); string backgroundimagename = string.valueof(v.gettag()); and should return image tag name "bg1" . now compare tag names or use further process if( backgroundimagename.equals(bg1)) { //do } else{ //do }

operating system - Get Key Code of Pressed Key from Python -

is possible python read key (such enter or escape or arrow key) pressed user , record keycode of key in variable? i looked @ python key binding/capture displays character press in shell. want record value in variable, no need print (and not python '\n' enter real keycode (like 13 think on windows) enter key). this works me. @mosherabaev right , code version. guess have find characters special keys (like '\r' enter). no clue characters arrow keys though... import wx user_input = str(raw_input()) user_input += '\r' #if press enter key print user_input if ord(user_input) == wx.wxk_return: print "hey" print "what"

java - NPE when using CamelBlueprintTestSupport -

i want create integration test camelblueprinttestsupport. start camelcontext looks ok @ first: [ main] ingrestjobadvertapioffirstbird info skipping starting camelcontext system property skipstartingcamelcontext set true. [ main] blueprintcamelcontext info apache camel 2.15.1.redhat-620133 (camelcontext: camel-1) starting routes starting. message within console: in main loop, have serious trouble: java.lang.nullpointerexception java.lang.nullpointerexception @ org.apache.felix.fileinstall.internal.directorywatcher.run(directorywatcher.java:303) camel version: 2.15.1.redhat-620133 the unit test: public class whenusingrestjobadvertapiofdemo extends camelblueprinttestsupport { @override protected string getblueprintdescriptor() { return "osgi-inf/blueprint/blueprint.xml"; } @override protected string[] loadconfigadminconfigurationfile() { return new string[]{"src/test/re...

xslt - Test for result tree fragment -

i'm trying create template either presents content, or inserts placeholder indicate absence of content: <xsl:template name="information"> <xsl:param name="content"> <xsl:choose> <xsl:when test="$content"> <content> <xsl:apply-templates select="$content/node()" /> </content> </xsl:when> <xsl:otherwise> <placeholder/> </xsl:otherwise> </xsl:choose> </xsl:template> this works well, until content result tree fragment: <xsl:call-template name="information"> <xsl:with-param name="content">yes</content> </xsl:call-template> i'm using microsoft .net xslt engine, can call msxsl:node-set() on parameter obtain workable node-set, don't know how test if parameter needs treatment. far lesser case content generated. ...

matlab - For each vector of the cell A, How to find all possible combinations of its components that are not contained in vectors of the cell B? -

for each vector of cell a , how find possible combinations of components not contained in vectors of cell b ? = {[2 3 6 21],[66 4 2 7],[84 56 66 47 45]}; b = {[5 6 9 20 21],[7 85 14 2 3],[5 66 84 10 23 35 56],[5 6 87 14 21 29]}; for a{1} , possible combinations satisfy condition: {[2 6],[2 21],[3 6],[3 21],[2 6 21],[2 3 6],[2 3 21],[3 6 21],[2 3 6 21]} [2 3] contained in b{2} [6 21] contained in b{1} try this: c = cell(1, numel(a)); ii = 1:numel(a) aux = arrayfun(@(x) num2cell(nchoosek(a{ii}, x), 2)', 1:numel(a{ii}), 'un', 0); aux = [aux{:}]; c{ii} = aux(~cellfun(@(a) any(cellfun(@(b) all(ismember(a, b)), b)), aux)); end the result in c . run celldisp(c{1}) see result a{1} , example. this code takes every vector in a , find possible combinations using nchoosek . then, checks if combination has values contained on vector of b , returning remaining combinations ont in b , putting them c .

javascript - keep file order using jquery file upload -

i looking @ upload script here: http://demo.tutorialzine.com/2013/05/mini-ajax-file-upload-form/ it using jquery file upload upload multiple files @ once. know how pass order of files selected upload.php script. ie. if have 1.jpg, 2.jpg, 3.jpg, 4.jpg, , 4 finishes uploading first, can upload.php receive variable tells it 4th image selected? jquery file upload have way of adding order form action perhaps? thanks in advance. it should automatically upload , read data in order received once hits upload.php layer. make sure upload files in order want them.

javascript - Node.js singleton module pattern that requires external inputs -

normally might create simple singleton object node.js: var foo = {}; module.exports = foo; or function foo(){} module.exports = new foo(); however what best way make clean singleton module needs external variable initialization? end making this: var value = null; function init(val){ if(value === null){ value = val; } return value; } module.exports = init; this way using module can pass in initializing value variable. way so: function baz(value){ this.value = value; } var instance = null; module.exports = function init(value){ if(instance === null){ instance = new baz(value); } return instance; } there's 2 problems encounter this: (1) minor, semantics wrong. can rename init getinstance, can't make same function literal mean "initialize , get" since different meanings. have have function 2 different things. create instance , retrieve , instance. don't since in cases need make sure argument initialize instance not nul...