Posts

android - xamarin navigate from one fragment to another -

i trying navigate on fragment click button in original fragment. how ever got exception image of exception image of code original fragment the problem passing layout in call of transaction.replace(), instead should pass id of viewgroup fragment inserted in layout. so layout of activity containing fragments should this: <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" <framelayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="fill_parent" /> </framelayout> and in fragmentstocksearch fragment, override oncreateview this: public override view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { return inflater.inflate(resource.layout.your_layout, null, false); } and fragment transaction...

PHP: mail() function is not sending emails to GMAIL -

i have subscription form. simple! email input, that's it. <input type="text" id="email" name="email" value=""> <button id="subscribe" type="button">subscribe</button> what want php send email me (ej, myemail@gmail.com ), account gmail account, subscriber's email address message. simple!...or thought. <?php $subscriber = filter_input(input_post, 'email'); /* send email */ $to = "myemail@gmail.com"; $subject = 'new subscriber'; $message = 'the following person wants subscribe: ' . "\r\n" . $subscriber; $headers = 'from: ' . $subscriber . "\r\n" . 'mime-version: 1.0' . "\r\n" . 'content-type: text/plain; charset=utf-8'; mail($to, $subject, $message, $headers); ?> the php code works, when use email not gmail ! can please me make work gmail? ...

Laravel search logic issue -

i developing search module in laravel 5.1 searches businesses along phone numbers (records). -- tables businesses: id, name, status records: id, business_id, number, note the search must return results when both business name , records note found given keywords. returns businesses if associated records(note) not match. here code:- $keywords = explode(" ", request::get('keywords')); $businesses = app\business; $businesses = $businesses->where(function ($query) use ($keywords) { foreach ($keywords $name) { $query->orwhere('name', 'like', "$name%"); } }); $businesses = $businesses->with(['records' => function ($query) use ($keywords) { $query->where('note', 'like', '%'.$keywords[0].'%'); foreach ($keywords $note) { $query->orwhere('note', 'like', "%$note%"); } }]); $businesses = $businesses->where('status...

regex - java regular expression for String surrounded by "" -

i have: string s=" \"son of god\"\"cried out\" day , ok "; this shown on screen as: "son of god""cried out" day , ok pattern phrasepattern=pattern.compile("(\".*?\")"); matcher m=phrasepattern.matcher(s); i want phrases surrounded "" , add them arraylist<string> . might have more 2 such phrases. how can each phrase , put arraylist ? with matcher you're 90% of way there. need #find method. arraylist<string> list = new arraylist<>(); while(m.find()) { list.add(m.group()); }

java - Recursively count the number of leaves in a binary tree without given parameters -

i struggling figure out how code recursive algorithm count number of leaves in binary tree (not complete tree). far traversing far left leaf , don't know return there. trying count loading leaves list , getting size of list. bad way go count. public int countleaves ( ) { list< node<e> > leaflist = new arraylist< node<e> >(); //binarytree<node<e>> treelist = new binarytree(root); if(root.left != null) { root = root.left; countleaves(); } if(root.right != null) { root = root.right; countleaves(); } if(root.left == null && root.right == null) { leaflist.add(root); } return(); } elaborating on @dasblinkenlight idea. want recursively call countleaves on root node & pass # caller. on following lines. public int countleaves() { return countleaves(root); } /** * recursively count nodes */ private static int countleaves...

swift string advancedBy is slow? -

so writing in swift practice online judge. here's issue: longest palindromic substring given string s, find longest palindromic substring in s. may assume maximum length of s 1000, , there exists 1 unique longest palindromic substring. so using dp solve in swift: class solution { func longestpalindrome(s: string) -> string { var hash = array(count: s.characters.count, repeatedvalue: array(count: s.characters.count, repeatedvalue: false)) in 0 ..< s.characters.count { hash[i][i] = true } var maxstart = 0 var maxend = 0 var maxcount = 1 in 1.stride(through: s.characters.count - 1, by: 1) { j in 0 ..< s.characters.count - 1 { if j + < s.characters.count { if isvalidpalindrome(j, j + i, s, hash) { hash[j][j + i] = true if maxcount < + 1 { maxcount = ...

How can I use dependency injection in a Gluon Desktop app? -

does know if there easy way use dependency injection within fxml controllers of gluon desktop (particleapplication) app? there @inject used things public class homecontroller { @inject particleapplication app; @inject private viewmanager viewmanager; @inject private statemanager statemanager; (as part of framework) able @inject own objects. edit: answer suggested use gluon ignite, i'm still having trouble figuring out. here of attempted code: my particleapplication class: package com.gluonapplication; import com.gluonhq.ignite.guice.guicecontext; import com.gluonhq.particle.application.particleapplication; import com.google.inject.abstractmodule; import javafx.scene.scene; import java.util.arrays; public class gluonapplication extends particleapplication { private guicecontext context = new guicecontext(this, () -> arrays.aslist(new guicemodule())); public gluonapplication() { super("gluon desktop application"); ...