Posts

Showing posts from September, 2012

java - Return and break in foreach-loop ArrayList -

i try execute function. private arraylist<note> notes; //adding notes in arraylist public note getnotebyday(calendar calendar) { (note note : notes) { if (note.getreminder().gettime() / constants.day_in_millis == calendar.gettimeinmillis() / constants.day_in_millis) { log.d("note_id", note.getname()); return note; } } return null; } but when call function different calendar i first note. i 2 calls of log.d() . when use break; instead return note; 1 call of log.d() where problem? 1) first note. that's because first note fulfill requirements in if statement. 2) 2 calls of log.d(). it means issue not in code in place calls method. use debugger or stacktrace determine , when calls method. multithread or multiclick - whatever environment or platform using. 3) when use break; instead return note; 1 call of

html5 - using heading tags moves div downwards -

i'm trying build header personal cv site, , reason using heading tags <h2></h2> <h3></h3> moves parent div .header downwards. when try move headings using margin-top moves whole div again. using normalize.css (tried removing nothing changed) along google font chose. otherwise code posted in fiddle below. can explain why happening , how fix it? thanks. html: <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>miha Šušteršič</title> <link rel="stylesheet" href="css/normalize.css"> <link href='http://fonts.googleapis.com/css?family=ubuntu:400,500,700&subset=latin-ext' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/style.css"> </head> &

node.js - Does nodejs create background task or child process to execute callback function -

does nodejs create background task or child process execute callback functions? how nodejs execute query below? mymodel.find({}, function (err, docs) { //do thing }); nodejs implements non-blocking i/o achieve these callbacks in single thread. uses event-loop. on demand of data, nodejs registers callback , send operation event loop. , when data available, callback called. say thread executing callback a. keep executing, , finds async task. registers new callback b async task. meanwhile waiting data of b, start executing other callback c. once c completed. check if data of b available. if so, executes b. otherwise executes other callback d... , on.. read deep understanding http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/

PHP resize HTTP_RAW_POST_DATA to save image -

how http_raw_post_data , can resize create smaller image. image saved disk have classes this, more http_raw_post_data not know how do if ( isset ( $globals["http_raw_post_data"] )) { //the image file name $filename = $_get['nome'].".jpg"; // binary stream $im = $globals["http_raw_post_data"]; //write $fp = fopen('saves/print/'.$filename, 'wb'); fwrite($fp, $im); fclose($fp); } if image coming multipart html form, don't think can use raw post data @ all...i empty if recall attempts read previously. instead, should use move_uploaded_file then, resize image via imagemagick or gd: resize image in php

java - Using Xpath to add a new value to attributes -

i need use xpath navigate analysis/analysis parameter attributes add in new value: as first step have tried retrieving value analysis tag cannot work (no sample value being retrieved, no output in console). can see going wrong here , further show how can add new value. import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import javax.xml.parsers.documentbuilder; import javax.xml.parsers.documentbuilderfactory; import javax.xml.parsers.parserconfigurationexception; import javax.xml.xpath.xpath; import javax.xml.xpath.xpathconstants; import javax.xml.xpath.xpathexpression; import javax.xml.xpath.xpathexpressionexception; import javax.xml.xpath.xpathfactory; import org.w3c.dom.document; import org.w3c.dom.node; import org.w3c.dom.nodelist; import org.xml.sax.saxexception; public class xpathtestreports { public static void main(string[] args) { try { string xpath = "/userdoc

python - SVM to gender recognition -

i've been working weeks in gender recognition project (in python) using @ first: fisherfaces feature extraction method , 1-nn classifier euclidean distance though not enough reliable (in humble opinion) i'm use svm im lost when have create , train model use in dataset of images, can't find solution commands need in http://scikit-learn.org . i've tried code doesn't work, dunno why have error while executing: file "prueba.py", line 46, in main clf.fit(r, r) file "/users/raul/anaconda/lib/python2.7/site-packages/sklearn/svm/base.py", line 139, in fit x = check_array(x, accept_sparse='csr', dtype=np.float64, order='c') file "/users/raul/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py", line 350, in check_array array.ndim) valueerror: found array dim 3. expected <= 2 and code: import os, sys import numpy np import pil.image image import cv2 sklearn import svm def read_images

python - writing into .csv-file inside of "while"-loop -

by using result = open("data/"+ name + "_" + timestamp + ".csv", "w") result.write("time; data1; data2; data3 \n")` i open file , fill column identifiers. using while true: timestamp = time.strftime("%h:%m:%s", time.localtime()) data1,data2,data3 = device.fetchdata() result.write(timestamp +";"+ str(data1) +";"+ str(data1) +";"+ str(data3) +"\n") time.sleep(seconds) the .csv-file should filled measuring data. problem is, if check file after exiting script, it's completely empty , not column identifiers present. however, if use for-loop, works should. very strange understanding. i assume want leave program running indefinitely collect data kind of sensor, , suspect issue default buffering open() call. firstly, should using "with" block @spirine suggests, in case slight modification in order: with open("data/"+ name +

ios - Animated UIImage in UITextView with TextKit -

i have uiimage contains multiple image frames , duration sliced animated gif file. if load image in uiwebview animate expected, want use uitextview instead. obvious choice use textkit custom nslayoutmanger , many custom nsattributedstring attributes achieve various drawing effects. have single uitextview i'd give nsattributedstring contains nstextattachment s of images need display inline. it's working fine except when load 1 of these animated uiimages , not animate through frames. thoughts on how accomplish this? i've come theoretical option: for each animated image add custom defined attribute when layout manager goes draw backgrounds, iterate attribute locate positions of attachment. callback text view create uiimageview s animated image, add subview, , call startanimating i have yet try this, it's hacky. i'm wondering if there's better option. in summary: want animate uiimage inside uitextview via nstextattachment inside nsattributeds

windows - How do I make a batchscript that displays only the last line of a textfile? -

this might have been answered before couldn't find on topic. im trying make chat messenger in batch , need display last line of textfile. here's tried (not elegant): @echo off /f %%x in (address.txt) set address=%%x :a if not exist "%address%" goto goto b :b set skipcount=1 :c /f "skip=%skipcount%" %%m in (%address%) echo %%m set m1=%%m :d /f %%m in (%address%) echo %%m > nul if not %%m==%m1% set skipcount=%skipcount%+1 goto d goto c this might work think full of mistakes example syntax errors^^ trying few hints wrong:) here's pure batch utility (requires no external tools) can shows range of numbered lines to show last line use this: call tailhead.bat -file=address.txt -end=1

css - Centering Elements Vertically with FlexBox -

attempting use flexbox (for demo purposes only) . i'm having trouble vertically centering text within parent .top-nav-bar . using justify-content: space-between i'm able 2 elements need them horizontally, i'm having no luck centering .contact , .help vertically within .top-nav-bar . attempts seem butt text against top edge of page. link codepen html: header.section1.box .top-nav-bar .contact p lorem ipsum dolor sit amet .help p lorem ipsum dolor sit amet css: .section1 background: image: url(url/of/image.jpg) size: cover position: top center repeat: no-repeat attachment: fixed .box overflow: hidden width: 100% height: 100vh background: color: #90281f .top-nav-bar max-width: 1200px width: 100% height: 40px margin: 0 auto font-size: 0.813em background: pink display: flex flex-direction: row align-items: center justify-content: space-between .contact background: red .

ios - Delete relationship between two entities MagicalRecord -

hi everyone, i'm using magicalrecord , try remove relation established between 2 entities contact <<--->> group a contact can related several groups , group can related several contacts. for instance, ben in group 1, alex in group 1, want remove ben group 1. any idea ? thanks in advance. you can use method coredatageneratedaccessors category of nsmanagedobject's subclass. if name of relation's set groups , name of generated method removegroupsobject .

Display progress during execution of a Maximo Java Customization -

i have written java customization client, attached button on 1 of maximo screens. processes data group of tables, (i'm using direct jdbc performance) calculations, , writes output table. takes while run, (10 - 50 seconds), during time browser displays busy cursor. i'm new product. know (i have read many many articles no joy) how might display kind of progress user? know can throw mxexception display dialog box, that's no good. i'd love display progress bar, although doubt possible. but can tell me whether can obtain reference field on currently-displayed maximo screen, , secondly, if update value (i'm thinking "% complete") dynamically refresh on-screen, though browser waiting on response maximo server? see can find in migration manager application. when building or deploying package, displays text messages / logs of has done far. it's not pretty progress bar, it's way more interesting spinning wheel of busy-ness.

Reloading page on modal close in AngularJS -

questions angularjs newbie. this 2 part problem. i have page has drop down (populated using web service), text box , button 'go'. button ng-click causes value of drop down , text box hit web service returns json use display grid (id, name). grid has delete button each row. inside 1 controller controllera. when delete button clicked, open modal http://angular-ui.github.io/bootstrap/ has yes , no button. modal in different controller controllerb. q1. how can value of id (row users want delete) in controllerb? using global var variable set in controllera , in controllerb don't think correct way? q2. when users click yes on modal (controllerb), how can reload page , display refreshed grid (controllera) - how can value of dropdown , textbox in controllerb , how can call controllera's ng-click function in controllerb? q1: check out this page example on how pass information modal dialog. need specify resolve property when calling $modal.open. q2:

Android : Search Icon not showing on Action Bar -

as title says trying add icon (for search purposes) in action bar item's title in 3 dot menu. here code use. menu_main.xml : <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity"> <item android:id="@+id/action_search" android:icon="@drawable/search" android:orderincategory="100" android:title="action_search" app:showasaction="always"/> </menu> the way inflate menu : @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.menu_main, menu); return super.oncreateoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) { // handle action b

Preserving session between node.js server reboots -

i'm developing node.js app , use nodemon run it. question how keep session open when make change in server, , nodemon reboot. this answer assumes you're using express or koa, 2 of more popular node.js web frameworks . in application, have line says following. express 4 var app = require( 'express' )() var session = require( 'express-session' ) app.use( session() ) // session middleware koajs var app = require( 'koa' )() var session = require( 'koa-session' ) app.use( session() ) // session middleware the guiding wisdom in web applications make world-facing side of stateless possible. means node.js server holds no information between requests , can destroyed , restarted anytime. a session stateful thing. because of this, need store session data in designed keep data uncorrupted in long run. commonly done through database (more secure) or browser cookie (less secure). the express-session module holds session informat

Java: Accessing private field via reflection (behaviour) -

junior in java; using reflection possible access private fields (not asking how, question 1 , question 2 ) ok. my questions related nature of behaviour. is there limitation? can access field of .class come across? during code, once set visibility of field lets "public" , changed forever or end of context (method, if, for...)? code below is ok everybody? mean, seniors programmers of stackoverflow, security breach? code [edited]: field f = obj.getclass().getdeclaredfield("field"); if (...) { f.setaccessible(true); // f accesible } // f accesible? is there limitation? yes - need several jvm permissions (most notably accessdeclaredmembers , suppressaccesschecks , marked big, bold warnings in docs) work; if jvm's security profile strict (say, much-maligned applets), code not work because these permissions not available. does changed forever? yes, long program keeps on running fields remain accessible (as long

haxe - HaxeFlixel. Access violation reading location 0x00000008 -

i have sprite can drag around on screen. want able drag sprite area (box). stands can drop sprite box, when drag directly inn, the program crashes. *im developing in flashdevelop windows gave me av option debug in vs. i debugged in vs , got error: unhandled exception @ 0x00accee9 in proj.exe: 0xc0000005: access violation reading location 0x00000008. relevant code: class drag extends flxgroup { var mousejoint:distancejoint; public inline function registerphyssprite(spr:flxnapesprite) { mouseeventmanager.add(spr, createmousejoint); } function createmousejoint(spr:flxsprite) { var body:body = cast(spr, flxnapesprite).body; mousejoint = new distancejoint(flxnapestate.space.world, body, new vec2(flxg.mouse.x, flxg.mouse.y), body.worldpointtolocal(new vec2(flxg.mouse.x, flxg.mouse.y)), 0, 0); mousejoint.space = flxnapestate.space; } override public function update():void { super.update(); if (mousejoint != null)

How can I transform this curl command into php curl code? -

i struggle everytime need use php curl. documentation pretty bad , endup doing trial , error. how can convert console command php curl code: curl -h "x-futuresimple-token: token" "https://appointments.futuresimple.com/api/v1/appointments.json" try this: $curl = curl_init(); curl_setopt( $curl, curlopt_returntransfer, 1 ); curl_setopt( $curl, curlopt_httpheader, array( 'x-futuresimple-token: token' ) ); curl_setopt( $curl, curlopt_url, 'https://appointments.futuresimple.com/api/v1/appointments.json' ); $result = curl_exec( $curl ); if ( $result === false ) { die( 'error fetching data: ' . curl_error( $curl ) ); } curl_close( $curl );

php - Can I charge a variable amount to Stripe as a subscription? -

i want use stripe api bill users every month amount specify. appears stripe not allow websites create subscription without first setting plan manually, restricting people can bill predesignated amounts. what best way this? you can! before talk more how works in practice, make sure understand when invoice open modificatio n. subscribing customer new plan, or updating customer's existing subscription if subscribing customer plan via api, won't able add custom fees after initial invoice created since closed. means you'll need setup custom amounts before initial invoice created. can in 1 of 2 ways: set account_balance when creating customer or updating customer's subscription. create invoice items before customer subscribed plan, , create subscription via update customer subscription call. in either case, we'll pull account balance or outstanding invoice items initial invoice, customer still charged setup fees. these one-time charges combining s

Bootstrap overlapping sections -

i have issue landing page based on bootstrap. on laptop looks fine, when minimize window sections start overlap each other although have used <div class="col-lg-12"> . expect when resize small (mobile) size should set section 1 below other, content top section covering bottom section. here's code ( github gist link ): <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>brand landing page</title> <!-- bootstrap core css --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- custom css --> <link href="

direct3d9 - Can WPF's D3DImage.IsFrontBufferAvailable be ignored? -

i followed common advice wpf's d3dimage.isfrontbufferavailable , stopped rendering when front buffer not available. after resetting d3d device property remains stuck false , never becomes true again. unless drop debugger , ignore property , continue rendering anyway, turns true , starts working again. even removing d3dimage.isfrontbufferavailable check entirely , ignoring property time seems work well. it seems that's ​recommended people other reasons: note if isfrontbufferavailable flag stating unavailable, you’ll still able render properly. trick ignore flag. what downsides ignoring it? (or there other trick makes not stop working?) i think recommended save resources if program not displayed (e.g. if user in lock screen). from experience can safely ignore it, keeps rendering if ui not shown user. if application not need lot of resources not have big impact on power consumption.

java - How to save child object automatically using a parent object using Hibernate and JPA? -

i have onetoone association. child class has foreign key primary key in parent class. problem unable save object of child class parent class. my add method follows: @transactional public void add(parentdto parentdto) { parentdto.setchild(child); child.setparent(parentdto); parent parent = mapper.map(parentdto, parent.class); parentrepository.save(parent); } jsp code follows; <form:form action="user.do" method="post" commandname="user"> <table> <tr> <td>user id</td> <td><form:input path="userid" /></td> </tr> <tr> <td>username</td> <td><form:input path="username" /></td> </tr> <tr> <td>password</td> <td><form:password path="password" /></td> </tr> <tr> <td>first name<

struts2 - Change Struts 2, i18n classes behavior when key is not found -

we used gettext in actions, setmessagekey in validators , <s:text> in jsp files i18n application. when struts 2 not find key in resource bundles returns key itself. example form.transfer.confirm . how can change behavior in way instead of key struts2 returns empty string. you need create custom implementation of textprovider , override gettext methods in it. 1) create class (e.g. emptydefaulttextprovider ) extending 1 of textprovider existing implementations (e.g. textprovidersupport ). 2) override gettext methods that: public string gettext(string key, string defaultvalue) { return super.gettext(key, ""); } 3) use custom class default text provider. put below in struts.xml. <constant name="struts.xworktextprovider" value="emptydefaulttextprovider" /> <bean type="com.opensymphony.xwork2.textprovider" name="emptydefaulttextprovider" class="packagep

javascript - jquery autocomplete accept without selecting from dropdown -

im using autocomplete plugin show user options choose when typing word. the problem here is: this code won't allow word if user types correctly word match avaible tags without clicking on showed items on dropdown. how can fix it?, have. $( "#fuente" ).autocomplete({ source: availabletags, change: function (event, ui) { if (ui.item == null || ui.item == undefined) { $("#fuente").val(""); $("#fuente").attr("disabled", false); $('#fuente').removeclass('fuenteboxcheck'); $('#fuente').addclass('fuenteboxncheck'); } else { $('#fuente').removeclass('fuenteboxncheck'); $('#fuente').addclass('fuenteboxcheck'); } } }); is there easy way fix this?, pls halp. thnx. ok.. did more research , fo

salesforce - Rerender a pageblock -

if run page first time, pageblocks shows message "choose user, account or opp" because nothing choosen. if have selected user, account or opp pageblock show list/detail of account or opp. if change user @ top, want panel/pageblocks resetet, how can that? added pageblocks rerender function, doesn't work. wrong code? <apex:form > <apex:pageblock id="pbuser"> <apex:pageblocksection > <apex:outputpanel > <apex:selectlist value="{!selecteduserid}" size="1" multiselect="false"> <apex:selectoptions value="{!listofuser}" /> <apex:actionsupport event="onchange" action="{!fetchaccounts}" <u><b>rerender="pbacc, pbopp, pboppd"</b></u>/> </apex:selectlist> </apex:outputpanel> </apex:pageblocksection> </apex:pageblock>

jquery - Javascript w2ui objects - can't get type -

Image
i got list of w2ui object on page. structure and part of inside want those, 1 type of 'w2layout'. i use jquery each go through that jquery.each(w2ui, function(key, value) { console.log(value); } ); but can't left part! i tried typeof (returns object ), , value.constructor (returns object too), tried use instanceof w2layout without success. json.stringify(value); throws error converting circular structure json how can this?

html - Extending jQuery vertical tab content area to the full page-width -

Image
i've setup vertical set of tabs outlined here . content area extends halfway across page. i've been trying adjust css allow flow far edge of page adding width='100%' attributes various ui css-tags or playing built in width attribute values , extend window starts putting actual content in wrong place. for example if remove width: 55em .ui-tabs-vertical white container area extend 'hello' text appears in following spot: how can adjust css allow content area full page width still start @ nicely padded left side of vertical tab list? jsfiddle example if setting width might fix it, try doing 1 : width: calc(100% - 162px); 162px assume width of left sidebar.

android - get @hide property via reflection -

i have use follow code localdisplaymetrics . displaymetrics localdisplaymetrics = new displaymetrics(); ((windowmanager) getsystemservice("window")).getdefaultdisplay() .getmetrics(localdisplaymetrics); i want localdisplaymetrics.noncompatwidthpixels .can via reflection? try this: displaymetrics localdisplaymetrics = new displaymetrics(); ((windowmanager) getsystemservice(window_service)).getdefaultdisplay().getmetrics(localdisplaymetrics); try { field field = displaymetrics.class.getdeclaredfield("noncompatwidthpixels"); field.setaccessible(true); int value = field.getint(localdisplaymetrics); } catch (nosuchfieldexception e) { e.printstacktrace(); } catch (illegalaccessexception e) { e.printstacktrace(); }

authentication - How to use AuthenticationManager SignIn when using OpenId -

we have need provide mixed mode authentication , we've spent weeks chasing down samples, , bits , pieces , have our claimsidentity built, need figure out way have owin recognize our claimsidentity logged in user. everything we've found far defining app.usecookieautentication in startup.auth.configureauth(). set authenticationtype = "cookies", set login path. however, use custom version of identity server 3 , in addition usecookieauthentication, use app.useopenidconnectauthentication. we've had issues setting usecookieauthentication loginpath. we've tried putting in , leaving empty. code use login our windows users, make calls identityserver, our tokens , claims. we use usermanager.createidentityasync follows. var _identity = await _usermanager.createidentityasync(_sluser, defaultauthenticationtypes.applicationcookie); everything appears here. then use identity following code: var _ctx = httpcontext.current.getowincontext(); var _auth

php - magic __get() on end($array) or $var -

i want access last element of array via php's magic __get method. i using php's end($array) return. if this: class fun { protected $var = 'test'; protected $arr = array(1, 2); public function __get($name) { return $this->$name; } public function get_array() { return end($this->arr); } } $obj = new fun(); var_dump($obj->var); //gives me: string(4) "test" var_dump($obj->get_array()); //gives me: int(2); everything working fine. far good. i don't want use different "getters" vars , arrays. want method find out if variable or array called , return value. i thought easy done via $name parameter, too: class funfun { protected $var = 'more test'; protected $arr = array(1, 2, 3); public function __get($name) { if(is_array($this->$name)) { $ret = end($this->$name); } else { $ret = $this->$name; } return $ret; } } $obj2 = new funfun(); var_dump($o

javascript - How much space does the localstorage key itself take up? -

Image
lets create localstorage key , give empty string. name of keyitem take same amount of space value per character? for instance does localstorage.setitem("keyitem","") //equal space of other 1 under? localstorage.setitem("key","item"); also, amount of keys matter? instance localstorage.setitem("key",""); //equal amount of storage 3 under combined? localstorage.setitem("k",""); localstorage.setitem("o",""); localstorage.setitem("h",""); i found function once calculate size of localstorage , sessionstorage objects, can't remember found it. here's code: storage.prototype.size = function(units) { 'use strict'; units = units ? units.touppercase() : 'mb'; var size = unescape(encodeuricomponent(json.stringify(this))).length; switch (units) { case 'b': return [size,'b'].join(' '

Intellij failed to detect file type -

i have intellij 13.1.3 ultimate , have been using php projects. files.php nicely hightlighted php. this morning had create new file called "report.php". @ first create right click > new > file, gave me no hightlighting. deleted , tried again right click > new > php file same result. ever way create it, thinks file txt (it seems so) , there no code highlighting. it's pretty frustrating. i have tested creation of new file different name "reports.php" time right click> new > php file, , came nicely highlighted. tried rename file "report.php" came no highlighting!! it seems intellij stuck name report.php being type text. i tried delete file, restart idea, recreate right way, no luck. tried power save mode on, , off. no luck. tried file > invalidate cache/restart, ... no luck. i'm out of options here... is there way force intellij interpret file? name "report" reserved word?!?!? how can stupid... edit:

How to get an integer on selenium IDE -

i got page want run code: i got css properties: <center> radicacion exitosa, numero radicacion: 12 - 132263… </center> i want store "132263" in variable because have copy , paste them in window, want know if there way number tag...specially "132263" because if store variable selenium ide full text. thanks using regex in javascript you: <tr> <td>storetext</td> <td>//center</td> <td>full</td> </tr> <tr> <td>storeeval</td> <td>var regex=/\-\s+(\d+)\s+\-/;regex.exec(storedvars['full'])[1];</td> <td>number</td> </tr> <tr> <td>echo</td> <td>${number}</td> <td></td> </tr> we're capturing text center tag , running regex grab number out of (using group (\d+) , returning [1]).

how to get a passed data from the url in codeigniter -

hi have data passed in url http://www.test.com/dashboard/john-doe i want page when enter http://www.test.com/dashboard/john-doe john doe name database retrieve when users can login. so dashboard controller how able page if passed data john-doe next dashboard controller? can me figured thing out? muchly appreicated controller below <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class dashboard extends ci_controller { public function __construct(){ parent::__construct(); $this->load->model('users_model', 'um'); $sessiondata = $this->session->userdata('loggedin'); $this->data['id'] = $sessiondata['userid']; if(!$this->session->userdata('loggedin')){ redirect('login'); } } public function index($slug){ echo $slug; exit; $this->data['title'] = 'dashboard | test';

back - mistake with finish an activity in android -

i have main activity 6 buttons. every button starts new activity. program worked after changed graphical attributes , made changes in theme mistake occurred . should press button 3 times return activity or exit main activity. suggestions? btn_weeks.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent arg1) { intent = new intent(mainactivity.this, weeks.class); startactivity(i); return false; } }); buttons should implements view.onclicklistener , not ontouchlistener .

Need to implement an instant messaging for iOS and Android? -

i'm building ios app boss, , have implement chat. app run on ios in future it's gonna run on android too, need cross-platform working solution. develop in swift, on iphone only. once logged in facebook , twitter or email you'll able send messages other users logged in app , online. know, waze style. i think cannot use imessage since app developed android too. i'm trying understand jabber totally new @ it, possible make such service in php? boss told me third party chat service, pay , stop cannot find right one. could me? there new tool named layer looking for. layer

Java avoiding null pointer exception in generic class -

okay here 2 classes.my aim insert in obt using generic class.in case trying strings.when call insert method in main keep getting: exception in thread "main" java.lang.nullpointerexception @ obtcomparable.insert(obtcomparable.java:37) @ findtest.main(findtest.java:12) i found problem: since var "data" null , can't use compare. the question: how can change "data" avoid null pointer exception(it string). generic obtcomparable class: public class obtcomparable<type extends comparable<type>> { private boolean empty; private type data; private obtcomparable left; private obtcomparable right; public obtcomparable() { setempty(); } private void setempty() { empty = true; data = null; /////////////////// problem // left = null; right = null; } private void setdata(type reqdata) { if (empty) { empty = false; left = new obtcomparable(); r

mysql - Displaying username on index.php -

mysql table contains following rows: id , user_name , name , password . on login form require user submit name , password , on submitting same direct user index.php page. after user login wish display value of "user_name" contains user full name, on top of index.php page. for example hello : user_name. how it? there many different ways (using session,cookies,localstorage etc). i'll show simple way using session; let's on top of page want have container displaying name, example : <div class='greet'> hello <?php echo $_session['username']; ?> </header> what want show if user logged : <?php if(isset($_session['username']): ?> <div class='greet'> hello <?php echo $_session['username']; ?> </header> <?php endif; ?> so now, if user logged, div created. when user trying log in (i'm guessing posting username , password php file , searching

java - How can I put a ExpandableListView into a ScrollView without it collapsing? -

i want use expandablelistview inside scrollview other views faced problem of self scroller in expandablelistview l tried disable problem height of expandablelistview , layout it's inside. want disable expandablelistview scroll resize expandablelistview & linearlayout contains when groupview clicked i googled solution , found 1 works listview only listview in scrollview i want make same workout expandablelistview (with custom adapter). here code: mainactivity.java package fablabegypt.android.expandablelistview2; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.motionevent; import android.view.view; import android.view.viewgroup; import android.widget.expandablelistview; import android.widget.linearlayout; import java.util.arraylist; import java.util.hashmap; import java.util.list; public class mainactivity extends actionbaractivity