问:
ionic app ,on click of a button not work
I am developing an app and this is second screen where i am getting problem.
There is a skip button and when i press it the "div containing text in it " should hide .

I have written codes in typescript file "home.ts" and have written html of it it in home.html and css in home.css

there are only 2 screens i have done with these codes,one is splash screen and other one is disclaimer or home screen where i am trying to hide the div with text on click of skip button

Here is home.ts code:

```<code>import { Component,ViewChild} from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl:'home.html'
})
export class HomePage {
@ViewChild('username')username;
@ViewChild('password')password;

  splash = true;

  constructor(public navCtrl: NavController ) {
    }
    showhide(){

      var toggle = function() {
      var mydiv = document.getElementById('div');
      if (mydiv.style.display === 'block' || mydiv.style.display === ''){
        mydiv.style.display = 'none';
      }
      else{
        mydiv.style.display = 'block';
      }
      }
    }

  ionViewDidLoad() {
    setTimeout(() => this.splash = false, 4000);

  }

    }

and here is home.html file

<html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="initial-scale=1,maximum-scale=1, user-scalable=no">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
            <script src="lib/jquery-1.11.1.js"></script>
            <script src="lib/ionic/js/ionic.bundle.js"></script>
            <script src="js/app.js"></script>
            <script src="js/controller.js"></script>
            <script src="js/show.js"></script>
            <script src="build/animation.css"></script>
        </head>
             <body ng-controller="imageshow_hide">
                    <ion-content>
                            <div id="custom-overlay"[style.display]="splash ? 'flex': 'none'">
                                    <div class="flb">
                                            <div class="Aligner-item Aligner-item--top">
                                            </div>
                                            <img src="assets/logo.png">
                                            <div class="Aligner-item Aligner-item--bottom">
                                            </div>
                                    </div>
                            </div>
                                <div class="scroll-content">
                                                <img class="image1" src="assets/bg2.jpg"/>

                                                <div id="hides" class="image2"><img src="assets/whitetop.png"/>
                                                        <h2 style="text-align:center">WHY SHOULD I USE THIS APP

                                                        </h2>
                                                                <p>Our thoughts and everything we see feel hear taste and smell
                                                                shapes the unconscious mind.
                                                                By listening to affirmations daily.guided meditation and performing simple NLP techniques
                                                                you can re-program your mind to focus on the results you desire in life and develop
                                                                positive patterns for motivation and action
                                                                </p>

                                                </div>
                                                <div id="hides" class="image3"><img src="assets/whitebottom.png"/>
                                                    <h2 style="text-align:center">HOW TO USE THIS APP</h2>
                                                    <p>Don't listen to any of these recordings
                                                        while operating machinery or driving.only listen to these materials if you
                                                        are in safe place where you can relax.
                                                        All contents provided within their applications are NOT meant to replace
                                                        any qualified medical treatment or health related advice.
                                                        If you suffer from any mental disorder,NOT Listen to this material.
                                                        MindVolution accepts No responsibility or liability for any injury,loss or damage
                                                        as direct or indirect result of the usage of the information here presented.
                                                    </p>

                                                </div>
                                                    <button (click)="showhide()" id="hides">
                                                    <img class="image4" ng-hide="checked" src="assets/skip.png"/>
                                                    </button>
                                                <img class="image5"src="assets/sound icon.png"/>
                                                <img class="image6"src="assets/sound icon.png"/>
                                </div>
                    </ion-content>
                </body>
    </html>
</code>```

答:
```<code>I am using this in my home.ts file

showhide(){

      var toggle = function() {
      var mydiv = document.getElementById('hidden');
      if (mydiv.style.display === 'block' || mydiv.style.display === ''){
        mydiv.style.display ='none';
      }
      else{
        mydiv.style.display ='block';
      }
      }
    }

Hidden is the id of two divs which i want to hide on click of button ( this button has an image inside it).this button has id =skipbtn

Here is html code of skip button where user will press to hide the tow divs containing image

<button click="showhide()" >
                                                    <img class="image4" id="skipbtn" ng-hide="checked" src="assets/skip.png"/>
                                                    </button>

Here are two divs which need to  be hide on click of skip button

<div class="scroll-content">
                                                <img class="image1" src="assets/bg2.jpg"/>

                                                <div id="hidden" class="image2"><img src="assets/whitetop.png"/>
                                                        <h2 style="text-align:center">WHY SHOULD I USE THIS APP

                                                        </h2>
                                                                    <p>Our thoughts and everything we see feel hear taste and smell
                                                                    shapes the unconscious mind.
                                                                    By listening to affirmations daily.guided meditation and performing simple NLP techniques
                                                                    you can re-program your mind to focus on the results you desire in life and develop
                                                                    positive patterns for motivation and action
                                                                </p>
                                                </div>
                                                <div id="hidden" class="image3"><img src="assets/whitebottom.png"/>
                                                    <h2 style="text-align:center">HOW TO USE THIS APP</h2>
                                                    <p>Don't listen to any of these recordings
                                                        while operating machinery or driving.only listen to these materials if you
                                                        are in safe place where you can relax.
                                                        All contents provided within their applications are NOT meant to replace
                                                        any qualified medical treatment or health related advice.
                                                        If you suffer from any mental disorder,NOT Listen to this material.
                                                        MindVolution accepts No responsibility or liability for any injury,loss or damage
                                                        as direct or indirect result of the usage of the information here presented.
                                                    </p>
                                                </div>
</code>```

Body:
I am developing an app and this is second screen where i am getting problem.
There is a skip button and when i press it the "div containing text in it " should hide .

I have written codes in typescript file "home.ts" and have written html of it it in home.html and css in home.css

there are only 2 screens i have done with these codes,one is splash screen and other one is disclaimer or home screen where i am trying to hide the div with text on click of skip button

Here is home.ts code:

import { Component,ViewChild} from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl:'home.html'
})
export class HomePage {
@ViewChild('username')username;
@ViewChild('password')password;

  splash = true;

  constructor(public navCtrl: NavController ) {
    }
    showhide(){

      var toggle = function() {
      var mydiv = document.getElementById('div');
      if (mydiv.style.display === 'block' || mydiv.style.display === ''){
        mydiv.style.display = 'none';
      }
      else{
        mydiv.style.display = 'block';
      }
      }
    }

  ionViewDidLoad() {
    setTimeout(() => this.splash = false, 4000);

  }

    }

and here is home.html file

            <meta charset="utf-8">
            <meta name="viewport" content="initial-scale=1,maximum-scale=1, user-scalable=no">

                    <ion-content>

WHY SHOULD I USE THIS APP

Our thoughts and everything we see feel hear taste and smell
                                                                shapes the unconscious mind.
                                                                By listening to affirmations daily.guided meditation and performing simple NLP techniques
                                                                you can re-program your mind to focus on the results you desire in life and develop
                                                                positive patterns for motivation and action

HOW TO USE THIS APP

Don't listen to any of these recordings
                                                        while operating machinery or driving.only listen to these materials if you
                                                        are in safe place where you can relax.
                                                        All contents provided within their applications are NOT meant to replace
                                                        any qualified medical treatment or health related advice.
                                                        If you suffer from any mental disorder,NOT Listen to this material.
                                                        MindVolution accepts No responsibility or liability for any injury,loss or damage
                                                        as direct or indirect result of the usage of the information here presented.

                                                    <button (click)="showhide()" id="hides">

                                                    </button>

                    </ion-content>


来源: stackexchange

问:
How to show footer in every page when printing an HTML Page
I am trying to create an html page which will be used for printing data using browser. I need to include a footer with it which will show up in every page at the bottom when printed and I have developed the following code for implementing this.

The following code is working fine, but the problem is when my contents inside the div  content gets long enough to make users scroll down the page, that time if I go to the print option of Google Chrome and see the print preview,  I can see the footer shows up in the first page, but not in the rest of the pages. But this same code works in firefox and the footer shows up in all the printed pages(and even shows up in the print preview).

Could you please help me to show up the footer in every pages when printed using Google chrome?

Thanks :)

```<code><html>
<head>

 <style type="text/css">
 html {margin:0;padding:0;border:0; overflow-y: scroll;}
 body { font-size:75%;color:#222; font-family: Geneva, Arial, Helvetica, sans-serif;}
 #container {margin:0 auto; height:100%; }
 #content{}
 #footer {position: fixed ; left: 0px; bottom: 0px; right: 0px; font-size:10px; }
 </style>

 </head>

<body>
 <div id="container">
    <div id="content">
       My Contents
    </div>

   <div id="footer">This is my Footer</div>

 </div>

</body>
</html>
</code>```

答:
You need to set in your footer:</p>

```<code>position:fixed;
bottom:0;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am trying to create an html page which will be used for printing data using browser. I need to include a footer with it which will show up in every page at the bottom when printed and I have developed the following code for implementing this.

The following code is working fine, but the problem is when my contents inside the div  content gets long enough to make users scroll down the page, that time if I go to the print option of Google Chrome and see the print preview,  I can see the footer shows up in the first page, but not in the rest of the pages. But this same code works in firefox and the footer shows up in all the printed pages(and even shows up in the print preview).

Could you please help me to show up the footer in every pages when printed using Google chrome?

Thanks :)

       My Contents

This is my Footer

Body:
You need to set in your footer:

position:fixed;
bottom:0;


问:
C# how calculate my price in my listbox
I am a beginner and trying to create a simple inventory for our future business :)

How can I do to this problem ?

I want to calculate the price when I click every button to my listbox.

Example:

When I add items and the price is 6 he display to the bottom (Total) 6 and when I add another and the price is 7 is added to 6 so the total will 13 what can I do to this scenario can I use foreach or something or I revise my code ? help guys thank you :)

enter image description here

```<code>private void button4_Click(object sender, EventArgs e)
{
    int sum = 0;
    if (listBox1.Items.Count >= 0)
    {
        listBox1.Items.Add(dataGridView1.CurrentRow.Cells[0].Value.ToString() + "                 " + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "                                                      " + Convert.ToInt32(dataGridView1.CurrentRow.Cells[2].Value.ToString()) + "                        " + Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString()));
        sum += Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());

    }
    label7.Text = sum.ToString();
}
</code>```

and I cannot deduct when I void the list of transaction

```<code>private void button6_Click(object sender, EventArgs e)
{
    if (listBox1.SelectedIndex != -1)
    {
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        sum -= Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());
    }
}
</code>```

答:
To deduct the amount based on selected row from the list, try this:</p>

```<code>ListBox.SlectedObjectCollection TheSelectedItem = new ListBox.SlectedObjectCollection(listBox1);

TheSelectedItem = listBox1.SelectedItems;

int sum = 0;
private void button6_Click(object sender, EventArgs e)
{
   //also ensure that the row is selected before clicking the button that's the only way the SelectedIndex click event will fire, pass the selected row value.
if(listBox1.TheSelectedItem.Count != 0)
{
   while (listBox1.SelectedIndex != -1)
     {
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        sum -= Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());
      }
  }
     label7.Text = sum.ToString();
}
</code>```

Title: C# how calculate my price in my listbox

Body:
I am a beginner and trying to create a simple inventory for our future business :)

How can I do to this problem ?

I want to calculate the price when I click every button to my listbox.

Example:

When I add items and the price is 6 he display to the bottom (Total) 6 and when I add another and the price is 7 is added to 6 so the total will 13 what can I do to this scenario can I use foreach or something or I revise my code ? help guys thank you :)

enter image description here

private void button4_Click(object sender, EventArgs e)
{
    int sum = 0;
    if (listBox1.Items.Count >= 0)
    {
        listBox1.Items.Add(dataGridView1.CurrentRow.Cells[0].Value.ToString() + "                 " + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "                                                      " + Convert.ToInt32(dataGridView1.CurrentRow.Cells[2].Value.ToString()) + "                        " + Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString()));
        sum += Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());

    }
    label7.Text = sum.ToString();
}

and I cannot deduct when I void the list of transaction

private void button6_Click(object sender, EventArgs e)
{
    if (listBox1.SelectedIndex != -1)
    {
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        sum -= Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());
    }
}

Body:
To deduct the amount based on selected row from the list, try this:

ListBox.SlectedObjectCollection TheSelectedItem = new ListBox.SlectedObjectCollection(listBox1);

TheSelectedItem = listBox1.SelectedItems;

int sum = 0;
private void button6_Click(object sender, EventArgs e)
{
   //also ensure that the row is selected before clicking the button that's the only way the SelectedIndex click event will fire, pass the selected row value.
if(listBox1.TheSelectedItem.Count != 0)
{
   while (listBox1.SelectedIndex != -1)
     {
        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        sum -= Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value.ToString());
      }
  }
     label7.Text = sum.ToString();
}


问:
Print while testing
I add several lines of System.out.println("xxx") in my junit test class but I can only see whether I pass the test not my printed message. I'm using android studio and how can I see the printed message in a junit test? Thanks!</p>

答:
You can use filters to limit the number of messages. Using multiple levels of logging, like verbose you can also limit the number of messages.

Perhaps it would be better to use Log.d('Chongye', 'This is my message'); Since you can filter your username and see if it is logged correctly. More information can be found here: https://developer.android.com/reference/android/util/Log.html

Title: Print while testing


问:
Rails Validation: Limit input to specific values
I'm looking for "the Rails Way" to write a validation that limits acceptable input values to a predetermined list.

In my case, I want to only accept the values "-5", "-2", "+2", "+5", and nil. However, I think this is best as a general question: how do you predefine a list of acceptable entry values in a Rails model?

Thanks!

答:
validates_inclusion_of should work.  For example:</p>

```<code>  validates_inclusion_of :attr, :in => [-5, -2, 2, 5], :allow_nil => true
</code>```

ContentLicense: CC BY-SA 2.5

Body:
validates_inclusion_of should work.  For example:

  validates_inclusion_of :attr, :in => [-5, -2, 2, 5], :allow_nil => true


问:
sum array from map result dynamically using javascript
I am getting the array from multidimensional array using map. Below is my code

```<code> var data = [{"name":"ramu","id":"719","gmail":"ramu@gmail.com","ph":988989898,"points":36},
        {"name":"ravi","id":"445","gmail":"ravi@gmail.com","ph":4554545454,"points":122},
        {"name":"karthik","id":"866","gmail":"karthik@gmail.com","ph":2332233232,"points":25}]
var result = data.map(function(arr, count) {
  return arr.points;
});
</code>```

Output is [36, 122, 25].
But i need the sum as 183?

答:
just write follwing code after your original code</p>

```<code>var result = result.reduce(add, 0);

function add(a, b) {
    return a + b;
}

console.log(result);
</code>```

Body:
I am getting the array from multidimensional array using map. Below is my code

 var data = [{"name":"ramu","id":"719","gmail":"ramu@gmail.com","ph":988989898,"points":36},
        {"name":"ravi","id":"445","gmail":"ravi@gmail.com","ph":4554545454,"points":122},
        {"name":"karthik","id":"866","gmail":"karthik@gmail.com","ph":2332233232,"points":25}]
var result = data.map(function(arr, count) {
  return arr.points;
});

Output is [36, 122, 25].
But i need the sum as 183?

Body:
just write follwing code after your original code

var result = result.reduce(add, 0);

function add(a, b) {
    return a + b;
}

console.log(result);


答:
Use Array's reduce() like the following:

var data = [{"name":"ramu","id":"719","gmail":"ramu@gmail.com","ph":988989898,"points":36},
    {"name":"ravi","id":"445","gmail":"ravi@gmail.com","ph":4554545454,"points":122},
    {"name":"karthik","id":"866","gmail":"karthik@gmail.com","ph":2332233232,"points":25}];

var result = data.reduce((sum, item) => sum + item.points ,0);
console.log(result);```

Title: sum array from map result dynamically using javascript

ContentLicense: CC BY-SA 4.0


问:
Configuration 'compile' in is deprecated, but all configurations are 'implementation'
I receive following warning while executing gradle in android:

```<code>Configuration 'compile' in project ':app' is deprecated.
</code>```

But all my dependencies included via implementation configuration. (And modules too)
Are there any "invisible" dependencies in gradle?

Here is my main build gradle file: https://pastebin.com/ZJe7zrwn

答:
I think you received warning because you use,

```<code>compileOnly "org.glassfish:javax.annotation:10.0-b28"
</code>```

a better explanation is given here,

Android Gradle Implementation vs CompileOnly Performance

Body:
I receive following warning while executing gradle in android:

Configuration 'compile' in project ':app' is deprecated.

But all my dependencies included via implementation configuration. (And modules too)
Are there any "invisible" dependencies in gradle?

Here is my main build gradle file: https://pastebin.com/ZJe7zrwn

Body:
I think you received warning because you use,

compileOnly "org.glassfish:javax.annotation:10.0-b28"

a better explanation is given here,

Android Gradle Implementation vs CompileOnly Performance


问:
How to make my if (condition) work only when it's > 768 px?
My script works, however it works only half way, since I'm giving if (condition) and it's working only after refresh the cache on the browser.

My main goal is to make my subheader fixed on desktop version and it should be not fixed on mobile devices

This is my code

```<code>var windowWidth = $(window).width();
if(windowWidth > 768){
    var fixedMenu = $('.subheader-wrapper.row');
    var navOffset = fixedMenu.offset().top;
    $(window).scroll(function () {
        var scrollPos = $(window).scrollTop();
        if(scrollPos > navOffset) {
            fixedMenu.addClass('fixed');
            fixedMenu.addClass('animated fadeIn');
        }
        else {
            fixedMenu.removeClass('fixed');
            fixedMenu.removeClass('animated fadeIn')
        }
        if ( window.location.pathname == '/' ||  window.location.pathname == '/o-kompanii' || window.location.pathname == '/otzyivyi' || window.location.pathname == '/vopros-otvet' ) {
            var infoUs = $('#info-us');
            var infoUsOff = infoUs.offset().top;
            if (scrollPos > infoUsOff - 480) {
                infoUs.find('div:first-child').addClass('animated fadeInLeft');
                infoUs.find('div:nth-child(2)').addClass('animated fadeInUp');
                infoUs.find('div:last-child').addClass('animated fadeInRight');
            }
        }

    });
}
</code>```

答:
I suggest this to use with the help of css for exact output. $(window).width(); might be different in different browsers. Therefore we can get the desired result using the help of css and media query.

```<code>.test {
        display: none;
    }
    @media only screen and (max-width: 767px) {
        .test {
            display: block;
        }
    }
</code>```

JQuery

```<code>$(window).on( "resize" , function () {
        if (jQuery(".test").is(":hidden")) {
            // CODE HERE
        }
    });
</code>```

Body:
My script works, however it works only half way, since I'm giving if (condition) and it's working only after refresh the cache on the browser.

My main goal is to make my subheader fixed on desktop version and it should be not fixed on mobile devices

This is my code

var windowWidth = $(window).width();
if(windowWidth > 768){
    var fixedMenu = $('.subheader-wrapper.row');
    var navOffset = fixedMenu.offset().top;
    $(window).scroll(function () {
        var scrollPos = $(window).scrollTop();
        if(scrollPos > navOffset) {
            fixedMenu.addClass('fixed');
            fixedMenu.addClass('animated fadeIn');
        }
        else {
            fixedMenu.removeClass('fixed');
            fixedMenu.removeClass('animated fadeIn')
        }
        if ( window.location.pathname == '/' ||  window.location.pathname == '/o-kompanii' || window.location.pathname == '/otzyivyi' || window.location.pathname == '/vopros-otvet' ) {
            var infoUs = $('#info-us');
            var infoUsOff = infoUs.offset().top;
            if (scrollPos > infoUsOff - 480) {
                infoUs.find('div:first-child').addClass('animated fadeInLeft');
                infoUs.find('div:nth-child(2)').addClass('animated fadeInUp');
                infoUs.find('div:last-child').addClass('animated fadeInRight');
            }
        }

    });
}

Body:
I suggest this to use with the help of css for exact output. $(window).width(); might be different in different browsers. Therefore we can get the desired result using the help of css and media query.

.test {
        display: none;
    }
    @media only screen and (max-width: 767px) {
        .test {
            display: block;
        }
    }

JQuery

$(window).on( "resize" , function () {
        if (jQuery(".test").is(":hidden")) {
            // CODE HERE
        }
    });


问:
Sum of price for each type of item
I'm new here and I dont know how to create table like other users do, so please bear with me. So i have two tables. The first table lists 3 types of item. The second table lists the types of the items and the price sold for each item. So for example,

Table 1 has Product A, B, C, Name of Origin, Date Ordered

Table 2 has

```<code>        Product A @ $50
        Product A @ $25
        Product A @ $10
        Product A @ $30
        Product B @ $10
        Product B @ $20
        Product C @ $5
        Product C @ $10
        Product C @ $25
</code>```

Now, i want to calculate the sum of product sold for each product type. That means i should have the output product A of 92.5, product B of 15, product C of 20. The thing is, my syntax only gives the same output for each product so for product A,B,C the output is 92.5. How do I fix it so it gives the proper result? Thanks!

答:
Since you want the SUM for EACH product type (i.e. A, B, and C). You need to use:

the aggregate function SUM(): returns the sum of a numeric column.

INNER JOIN keyword: to join column price with product name of the two different tables together, based on matching values.

GROUP BY statement: group the result-set by one or more columns.

Tip: if you see the keywords, for each X, that almost always means GROUP BY X.

I cannot see the actual design of your tables, but this should be enough to solve your issue:

```<code>SELECT p.producttype, SUM(t.price) AS totalprice FROM Table1 AS p
JOIN Table2 as t
ON p.productid = t.productid
GROUP BY p.producttype
</code>```

I hope this helps.

Title: Sum of price for each type of item

Body:
I'm new here and I dont know how to create table like other users do, so please bear with me. So i have two tables. The first table lists 3 types of item. The second table lists the types of the items and the price sold for each item. So for example,

Table 1 has Product A, B, C, Name of Origin, Date Ordered

Table 2 has

        Product A @ $50
        Product A @ $25
        Product A @ $10
        Product A @ $30
        Product B @ $10
        Product B @ $20
        Product C @ $5
        Product C @ $10
        Product C @ $25

Now, i want to calculate the sum of product sold for each product type. That means i should have the output product A of 92.5, product B of 15, product C of 20. The thing is, my syntax only gives the same output for each product so for product A,B,C the output is 92.5. How do I fix it so it gives the proper result? Thanks!

Body:
Since you want the SUM for EACH product type (i.e. A, B, and C). You need to use:

the aggregate function SUM(): returns the sum of a numeric column.

INNER JOIN keyword: to join column price with product name of the two different tables together, based on matching values.

GROUP BY statement: group the result-set by one or more columns.

Tip: if you see the keywords, for each X, that almost always means GROUP BY X.

I cannot see the actual design of your tables, but this should be enough to solve your issue:

SELECT p.producttype, SUM(t.price) AS totalprice FROM Table1 AS p
JOIN Table2 as t
ON p.productid = t.productid
GROUP BY p.producttype

I hope this helps.


问:
changing notebook page title to bold in Wxpython
I have the following code:

```<code>self.NB = wx.Notebook(self.panel_1, -1, style=0)
self.NB_Partsnote= NB_Parts(self.NB,None,userId)
self.NB_Parts2note = NB_Parts2(self.NB,None,userId)
self.NB.AddPage(self.NB_Partsnote,_("Parts"))
self.NB.AddPage(self.NB_Parts2note ,_("Parts2"))
</code>```

This create the notebook and add 2 tabs.

in Parts2 I have a textctrl with readonly data:

```<code>self.cellPhone = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
</code>```

What I want is when self.cellPhone has value then the Parts2 title of the notebook to be BOLD

I tried to do:

```<code>class NB_Parts2(GeneralPanel):
    def __init__(self,parent,poId,userId, toolbar=None):
    more code...
    if self.cellPhone.GetValue() <> '':
        SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT,
                             wx.FONTWEIGHT_BOLD,
                             wx.FONTSTYLE_NORMAL))
</code>```

But this doesn't work. nothing happens. I tried also to remove the condition so it will always be BOLD but still nothing happens.

How can I do that?

答:
In addition to Jake’s answer, you may also try FlatNotebook or AuiNotebook to get the effect you are looking for. Docs:

https://wxpython.org/Phoenix/docs/html/wx.lib.agw.flatnotebook.html#module-wx.lib.agw.flatnotebook

https://wxpython.org/Phoenix/docs/html/wx.lib.agw.aui.auibook.AuiNotebook.html#wx.lib.agw.aui.auibook.AuiNotebook

Andrea.

Body:
I have the following code:

self.NB = wx.Notebook(self.panel_1, -1, style=0)
self.NB_Partsnote= NB_Parts(self.NB,None,userId)
self.NB_Parts2note = NB_Parts2(self.NB,None,userId)
self.NB.AddPage(self.NB_Partsnote,_("Parts"))
self.NB.AddPage(self.NB_Parts2note ,_("Parts2"))

This create the notebook and add 2 tabs.

in Parts2 I have a textctrl with readonly data:

self.cellPhone = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)

What I want is when self.cellPhone has value then the Parts2 title of the notebook to be BOLD

I tried to do:

class NB_Parts2(GeneralPanel):
    def __init__(self,parent,poId,userId, toolbar=None):
    more code...
    if self.cellPhone.GetValue() <> '':
        SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT,
                             wx.FONTWEIGHT_BOLD,
                             wx.FONTSTYLE_NORMAL))

But this doesn't work. nothing happens. I tried also to remove the condition so it will always be BOLD but still nothing happens.

How can I do that?


问:
Add Customize action ng2-smart-table but no action added
I'm trying create customize action but something went wrong, the code not given me custom action button

My settings, I added custom button inside actions:

```<code>settings = {
actions: {
  edit: false,
  custom: [
    {
      name: 'routeToAPage',
      title: `<i class="ion-person" title="Xem thông tin người nhận Giftcode"></i>`
    }
  ],
},
add: {
  addButtonContent: '<i class="ion-ios-plus-outline"></i>',
  createButtonContent: '<i class="ion-checkmark"></i>',
  cancelButtonContent: '<i class="ion-close"></i>',
  confirmCreate: true
},
columns: {
  stt: {
    title: 'STT',
    editable: false,
  },
},
pager : {
    display : true,
    perPage: 10
}
};
</code>```

My Html code:

```<code>      <ba-card class="smart-table-container">
          <ng2-smart-table
          [settings]="settings"
          [source]="source"
          (deleteConfirm)="onDeleteConfirm($event)"
          (custom)="onCustom($event)"
          ></ng2-smart-table>
      </ba-card>
</code>```

What's my problem?

Thanks!

答:
i have tried this. Do go through my code
      source: LocalDataSource;</p>

```<code>  settings = {
   columns: {
  Status: {
    title: 'Status'
    , class: 'align-centerr'
  },
  FullName: {
    title: 'Full Name'
  },
  JobTitle: {
    title: 'Job Title'
  },
  Department: {
    title: 'Department'
  },
  EmailAddress: {
    title: 'Email Address'
  },
  MobilePhone: {
    title: 'Mobile No'
  },

},
actions: {
  edit: false,
  custom: [{ name: 'Edit', title: `<i  class="fa fa-edit"></i>` },
    { name: 'Activate', title: `<i class="fa fa-toggle-on"></i>` },
    { name: 'Deactivate', title: `<i  class="fa fa-toggle-off"></i>` }
  ],

},

delete: {
  deleteButtonContent: '',
  confirmDelete: true
},
add: null,
defaultStyle: false
  ,
    rowClassFunction: (row) => {
    if (row.data.Status === 'Inactive')
   {
         return 'success-table';
   } else if (row.data.Status === 'Active') {
    return 'warning-table';

  }
}
</code>```

Body:
I'm trying create customize action but something went wrong, the code not given me custom action button

My settings, I added custom button inside actions:

settings = {
actions: {
  edit: false,
  custom: [
    {
      name: 'routeToAPage',
      title: `<i class="ion-person" title="Xem thông tin người nhận Giftcode"></i>`
    }
  ],
},
add: {
  addButtonContent: '',
  createButtonContent: '',
  cancelButtonContent: '',
  confirmCreate: true
},
columns: {
  stt: {
    title: 'STT',
    editable: false,
  },
},
pager : {
    display : true,
    perPage: 10
}
};

My Html code:

      <ba-card class="smart-table-container">
          <ng2-smart-table
          [settings]="settings"
          [source]="source"
          (deleteConfirm)="onDeleteConfirm($event)"
          (custom)="onCustom($event)"
          ></ng2-smart-table>
      </ba-card>

What's my problem?

Thanks!

Body:
i have tried this. Do go through my code
      source: LocalDataSource;

  settings = {
   columns: {
  Status: {
    title: 'Status'
    , class: 'align-centerr'
  },
  FullName: {
    title: 'Full Name'
  },
  JobTitle: {
    title: 'Job Title'
  },
  Department: {
    title: 'Department'
  },
  EmailAddress: {
    title: 'Email Address'
  },
  MobilePhone: {
    title: 'Mobile No'
  },

},
actions: {
  edit: false,
  custom: [{ name: 'Edit', title: `<i  class="fa fa-edit"></i>` },
    { name: 'Activate', title: `<i class="fa fa-toggle-on"></i>` },
    { name: 'Deactivate', title: `<i  class="fa fa-toggle-off"></i>` }
  ],

},

delete: {
  deleteButtonContent: '',
  confirmDelete: true
},
add: null,
defaultStyle: false
  ,
    rowClassFunction: (row) => {
    if (row.data.Status === 'Inactive')
   {
         return 'success-table';
   } else if (row.data.Status === 'Active') {
    return 'warning-table';

  }
}


问:
passing a text from one form to another in C++
I have two forms, one with QLineEdit and a button. other form have only QLabel. when somebody enters a text into first form and click the button, I need to open the second form displaying the text in the QLabel of second form. please any example how to do this will be highly appreciated.

and I'm doing this project in QT creator

答:
There are many options to achieve this. I'll show you one.
When you press the button, the form should appear.
Let's give it a text in a constructor which should be written on a label

```<code>void MainWindow::on_pushButton_clicked() {
    if (ui->lineEdit->text().isEmpty()) {
        //
    }

    Form *form = new Form(ui->lineEdit->text());
    form->show();
}
</code>```

In your QWidget or QDialog form

```<code>#include "form.h"
#include "ui_form.h"

Form::Form(QString value, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

    ui->label->setText(value);
}

Form::~Form()
{
    delete ui;
}
</code>```

Body:
There are many options to achieve this. I'll show you one.
When you press the button, the form should appear.
Let's give it a text in a constructor which should be written on a label

void MainWindow::on_pushButton_clicked() {
    if (ui->lineEdit->text().isEmpty()) {
        //
    }

    Form *form = new Form(ui->lineEdit->text());
    form->show();
}

In your QWidget or QDialog form

#include "form.h"
#include "ui_form.h"

Form::Form(QString value, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);

    ui->label->setText(value);
}

Form::~Form()
{
    delete ui;
}


问:
Calculate year over year increase SQL Server 2008R2
Below is my table structure.  I need to calculate rent for length of lease for each properties:

Let's look at PropertyID = 12077:

Area = 1280

StartDate = 2023-02-01

EndDate = 2027-10-31

BaseRent = 21.53

RentIncreasePercent = .04 (4 percent)

IncreaseRepeatMonths = 12 months (NOTE:  First 12 months there won't be any increase)

Since this property lease starts and ends between year 2023 and 2028, I'd like to know (in separate row per year) amount of rent to be collected each year.  This would take percent increase every 12 months (compound rent increase) into consideration.

Example:

21.53 * 1280 would give rent for first 12 months.  However, lease started in February so year 2023 total rent amount would be = ((21.23 * 1280)/12) * 11

For year 2024, first month rent would be = (21.23 * 1280)/12 because rent only increases every 12 months.  For next 11 months of 2024, rent would be ((12.23 * 1.04 * 1280)/12)* 11.

For year 2025, first month rent would be (12.23 * 1.04 *1280)/12).  However, next 11 months of 2025 would be ((12.72 * 1.04 * 1280)/12)*11.  12.72 comes from compound increase.

How would I go about coming up with a view to do this?  Most confusing part to me is not knowing how to accommodate for lease start date when it is not starting on January.

```<code>declare @table table
(
    PropertyID int,
    area int,
    StartDate date,
    EndDate date,
    BaseRent decimal(12,2),
    RentIncreaseBasis varchar(30),
    RentIncreasePercent decimal(5,2),
    IncreaseRepeatMonths int

)

insert @table values (12076,    5627,   '2024-01-01',   '2028-12-31',   '16.52',    '% Increase',   0.03, 12)
insert @table values (12077,    1280,   '2023-02-01',   '2027-10-31',   '21.53',    '% Increase',   0.04, 12)
insert @table values (12078,    1000,   '2017-03-01',   '2025-11-30',   '23.52',    '% Increase',   0.01, 12)
insert @table values (12079,    2000,   '2020-02-01',   '2024-09-30',   '15.57',    '% Increase',   0.05, 12)
insert @table values (12080,    3000,   '2018-05-01',   '2020-08-31',   '18.58',    '% Increase',   0.04, 12)
insert @table values (12081,    4000,   '2019-08-01',   '2020-12-31',   '22.56',    '% Increase',   0.03, 12)
insert @table values (12082,    5000,   '2017-02-01',   '2028-03-31',   '19.53',    '% Increase',   0.02, 12)

select * from @table
</code>```

答:
I recommend to use a calendar table which containts all the months from your table.
I hope my example will work in SQL 2008.</p>

```<code>-- here is your code

-- the calendar table
DECLARE @MonthCalendar table(
  [Month] date PRIMARY KEY
)

DECLARE @MinDate date,@MaxDate date

-- get min and max date
SELECT
  @MinDate=MIN(StartDate),
  @MaxDate=MAX(EndDate)
FROM @table

-- fill the calendar table
;WITH monthCTE AS(
  SELECT CAST(@MinDate AS date) [Month]

  UNION ALL

  SELECT DATEADD(MONTH,1,[Month])
  FROM monthCTE
  WHERE [Month]<@MaxDate
)
INSERT @MonthCalendar([Month])
SELECT [Month]
FROM monthCTE
OPTION(MAXRECURSION 0);

-- final query
SELECT
  *,
  (BaseRent*Area*(1+RentIncreasePercent*IncreaseCount))/12 MonthRentAmount,
  (1+RentIncreasePercent*IncreaseCount) TotalPercent
FROM
  (
    SELECT *,(ROW_NUMBER()OVER(PARTITION BY t.PropertyID ORDER BY m.[Month])-1)/12 IncreaseCount
    FROM @table t
    JOIN @MonthCalendar m ON m.[Month] BETWEEN t.StartDate AND t.EndDate
    --WHERE t.PropertyID=12077
  ) q

-- query for total amounts by PropertyIDs and Years
SELECT
  PropertyID,
  YEAR(StartDate) [Year],
  SUM((BaseRent*Area*(1+RentIncreasePercent*IncreaseCount))/12) YearRentAmount
FROM
  (
    SELECT *,(ROW_NUMBER()OVER(PARTITION BY t.PropertyID ORDER BY m.[Month])-1)/12 IncreaseCount
    FROM @table t
    JOIN @MonthCalendar m ON m.[Month] BETWEEN t.StartDate AND t.EndDate
    --WHERE t.PropertyID=12077
  ) q
GROUP BY PropertyID,YEAR(StartDate)
ORDER BY PropertyID,[Year]
</code>```

Body:
Below is my table structure.  I need to calculate rent for length of lease for each properties:

Let's look at PropertyID = 12077:

Area = 1280

StartDate = 2023-02-01

EndDate = 2027-10-31

BaseRent = 21.53

RentIncreasePercent = .04 (4 percent)

IncreaseRepeatMonths = 12 months (NOTE:  First 12 months there won't be any increase)

Since this property lease starts and ends between year 2023 and 2028, I'd like to know (in separate row per year) amount of rent to be collected each year.  This would take percent increase every 12 months (compound rent increase) into consideration.

Example:

21.53 * 1280 would give rent for first 12 months.  However, lease started in February so year 2023 total rent amount would be = ((21.23 * 1280)/12) * 11

For year 2024, first month rent would be = (21.23 * 1280)/12 because rent only increases every 12 months.  For next 11 months of 2024, rent would be ((12.23 * 1.04 * 1280)/12)* 11.

For year 2025, first month rent would be (12.23 * 1.04 *1280)/12).  However, next 11 months of 2025 would be ((12.72 * 1.04 * 1280)/12)*11.  12.72 comes from compound increase.

How would I go about coming up with a view to do this?  Most confusing part to me is not knowing how to accommodate for lease start date when it is not starting on January.

declare @table table
(
    PropertyID int,
    area int,
    StartDate date,
    EndDate date,
    BaseRent decimal(12,2),
    RentIncreaseBasis varchar(30),
    RentIncreasePercent decimal(5,2),
    IncreaseRepeatMonths int

)

insert @table values (12076,    5627,   '2024-01-01',   '2028-12-31',   '16.52',    '% Increase',   0.03, 12)
insert @table values (12077,    1280,   '2023-02-01',   '2027-10-31',   '21.53',    '% Increase',   0.04, 12)
insert @table values (12078,    1000,   '2017-03-01',   '2025-11-30',   '23.52',    '% Increase',   0.01, 12)
insert @table values (12079,    2000,   '2020-02-01',   '2024-09-30',   '15.57',    '% Increase',   0.05, 12)
insert @table values (12080,    3000,   '2018-05-01',   '2020-08-31',   '18.58',    '% Increase',   0.04, 12)
insert @table values (12081,    4000,   '2019-08-01',   '2020-12-31',   '22.56',    '% Increase',   0.03, 12)
insert @table values (12082,    5000,   '2017-02-01',   '2028-03-31',   '19.53',    '% Increase',   0.02, 12)

select * from @table

Body:
I recommend to use a calendar table which containts all the months from your table.
I hope my example will work in SQL 2008.

-- here is your code

-- the calendar table
DECLARE @MonthCalendar table(
  [Month] date PRIMARY KEY
)

DECLARE @MinDate date,@MaxDate date

-- get min and max date
SELECT
  @MinDate=MIN(StartDate),
  @MaxDate=MAX(EndDate)
FROM @table

-- fill the calendar table
;WITH monthCTE AS(
  SELECT CAST(@MinDate AS date) [Month]

  UNION ALL

  SELECT DATEADD(MONTH,1,[Month])
  FROM monthCTE
  WHERE [Month]<@MaxDate
)
INSERT @MonthCalendar([Month])
SELECT [Month]
FROM monthCTE
OPTION(MAXRECURSION 0);

-- final query
SELECT
  *,
  (BaseRent*Area*(1+RentIncreasePercent*IncreaseCount))/12 MonthRentAmount,
  (1+RentIncreasePercent*IncreaseCount) TotalPercent
FROM
  (
    SELECT *,(ROW_NUMBER()OVER(PARTITION BY t.PropertyID ORDER BY m.[Month])-1)/12 IncreaseCount
    FROM @table t
    JOIN @MonthCalendar m ON m.[Month] BETWEEN t.StartDate AND t.EndDate
    --WHERE t.PropertyID=12077
  ) q

-- query for total amounts by PropertyIDs and Years
SELECT
  PropertyID,
  YEAR(StartDate) [Year],
  SUM((BaseRent*Area*(1+RentIncreasePercent*IncreaseCount))/12) YearRentAmount
FROM
  (
    SELECT *,(ROW_NUMBER()OVER(PARTITION BY t.PropertyID ORDER BY m.[Month])-1)/12 IncreaseCount
    FROM @table t
    JOIN @MonthCalendar m ON m.[Month] BETWEEN t.StartDate AND t.EndDate
    --WHERE t.PropertyID=12077
  ) q
GROUP BY PropertyID,YEAR(StartDate)
ORDER BY PropertyID,[Year]


问:
How to customize datapoint labels in iOS Charts?
I'm trying to make my datapoint labels in a linechart display a custom string instead of their actual number (using the iOS Charts/ Charts library). I want to know if there is something like IAxisFormatter which I used to format my x and y axis labels.

I was wondering if anyone knows how exactly to do that in Swift? I can't seem to find any examples online. Thanks!

答:
in my case my data set has values of y, x is index

```<code>// this shows date string instead of index
let dates = ["11/01", "11/02", "11/03", "11/04"...etcs]
chartView.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)
</code>```

after set axis values

Body:
in my case my data set has values of y, x is index

// this shows date string instead of index
let dates = ["11/01", "11/02", "11/03", "11/04"...etcs]
chartView.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)

after set axis values


问:
Java: static abstract (again) - best practice how to work around
I theoretically understand the point why there is no abstract static in Java, as explained for instance in Why can't static methods be abstract in Java .

But how do I solve such a problem then?

My application uses files of a few types, which I want to assign static properties like a description of that file type (like "data file", the other being "config file", etc.).
Obviously, I would put that into a static String so that the description is accessible without instancing a file (useful for the GUI f.i.).
On the other hand, obviously all file types should have some common methods like getStatus(), which obviously I want to inherit from a common superclass MyFileType.

getDescription() would of course be abstract in the superclass.

Tried using a combination of a superclass and an interface, but similar problem: A static implementation of an abstract method is not allowed.

How would a Java guru solve this?
Is it really such a bad implementation that I want to create?

Many thanks,
Philipp

答: Sounds like you need to use a singleton. Basically, you call a static method like MyFileTypes.getDataFileInstance() which creates a single instance (or reuses if already created) of an object and when you first create it setup the 'constants' as needed. I'll see if I can find you a good example but your post isn't very clear about how you want to use it.


问:
Export TODOs in Android Studio/IntelliJ
I have a project with a bunch of TODOs.

Is there any way to export all the TODOs from project to some file?

Is there any feature/trick/plugin to achieve this in Android Studio/IntelliJ?

答: There is no special action to export todo list, but in IntelliJ you can run the "TODO comment" inspection, and export the inspection results.</p>

Title: Export TODOs in Android Studio/IntelliJ


问:
Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?
I am continuously receiving this error.

I am using mySQL Workbench and from what I am finding is that root's schema privileges are null. There are no privileges at all.

I am having troubles across platforms that my server is used for and this has been all of a sudden issue.

root@127.0.0.1 apparently has a lot of access but I am logged in as that, but it just assigns to localhost anyways - localhost has no privileges.

I have done a few things like FLUSH HOSTS, FLUSH PRIVILEGES, etc
but have found no success from that or the internet.

How can I get root its access back? I find this frustrating because when I look around people expect you to "have access" but I don't have access so I can't go into command line or anything and GRANT myself anything.

When running SHOW GRANTS FOR root this is what I get in return:

Error Code: 1141. There is no such grant defined for user 'root' on
  host '%'

答:
I worked on Access Denied for User 'root'@'localhost' (using password: YES) for several hours, I have found following solution,</p>

```<code>The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf

the line was either
bind-address = 127.0.0.1
            (or)
bind-address = localhost
            (or)
bind-address = 0.0.0.0

I should prefer that 127.0.0.1

I should also prefer 0.0.0.0, it is more flexible
because which will allow all connections
</code>```

Body:
I worked on Access Denied for User 'root'@'localhost' (using password: YES) for several hours, I have found following solution,

The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf

the line was either
bind-address = 127.0.0.1
            (or)
bind-address = localhost
            (or)
bind-address = 0.0.0.0

I should prefer that 127.0.0.1

I should also prefer 0.0.0.0, it is more flexible
because which will allow all connections


答:
Did you have tried this?

```<code>Log.e("YOUR TITLE MESSAGE", "THE MESSAGE");
</code>```

You can see the message on android monitor.

Title: Print while testing

Body: I add several lines of System.out.println("xxx") in my junit test class but I can only see whether I pass the test not my printed message. I'm using android studio and how can I see the printed message in a junit test? Thanks!

Body:
Did you have tried this?

Log.e("YOUR TITLE MESSAGE", "THE MESSAGE");

You can see the message on android monitor.


问:
Resolving configuration 'debugCompile' directly is not allowed

FAILURE: Build failed with an exception.

What went wrong:
Could not determine the dependencies of task ':app:extractIncludeDebugProto'.
Resolving configuration 'debugCompile' directly is not allowed

Try:
Run with --info or --debug option to get more log output.

Exception is:

org.gradle.api.internal.tasks.TaskDependencyResolveException: Could
  not determine the dependencies of task
  ':app:extractIncludeDebugProto'.  at
  org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.resolve(CachingTaskDependencyResolveContext.java:68)
    at
  org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:56)
    at
  org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.addToTaskGraph(DefaultTaskExecutionPlan.java:175)
    at
  org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.addTasks(DefaultTaskGraphExecuter.java:111)
    at
  org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:47)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
    at
  org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
    at
  org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
    at
  org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36)
    at
  org.gradle.initialization.DefaultGradleLauncher$CalculateTaskGraph.run(DefaultGradleLauncher.java:268)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at
  org.gradle.initialization.DefaultGradleLauncher.constructTaskGraph(DefaultGradleLauncher.java:175)
    at
  org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:130)
    at
  org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
    at
  org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
    at
  org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
    at
  org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
    at
  org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
    at
  org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
    at
  org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
    at
  org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at
  org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at
  org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at
  org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at
  org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at
  org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at
  org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at
  org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
    at
  org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
    at
  org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
    at
  org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
    at
  org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
    at
  org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
    at
  org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
    at
  org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at
  org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at
  org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at
  org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
    at
  org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
    at
  org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    at
  org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    at
  org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
    at
  org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
    at
  org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
    at
  org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    at
  org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at
  org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at
  org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)    at
  org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
    at
  org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
    at
  org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at
  org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at
  org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at
  org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
    at
  org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at
  org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at
  org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
  Caused by: java.lang.IllegalStateException: Resolving configuration
  'debugCompile' directly is not allowed    at
  org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.assertResolvingAllowed(DefaultConfiguration.java:898)
    at
  org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getBuildDependencies(DefaultConfiguration.java:516)
    at
  org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getBuildDependencies(Unknown
  Source)   at
  org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext$TaskGraphImpl.getNodeValues(CachingTaskDependencyResolveContext.java:94)
    at
  org.gradle.internal.graph.CachingDirectedGraphWalker$GraphWithEmpyEdges.getNodeValues(CachingDirectedGraphWalker.java:202)
    at
  org.gradle.internal.graph.CachingDirectedGraphWalker.doSearch(CachingDirectedGraphWalker.java:112)
    at
  org.gradle.internal.graph.CachingDirectedGraphWalker.findValues(CachingDirectedGraphWalker.java:64)
    at
  org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.doResolve(CachingTaskDependencyResolveContext.java:77)
    at
  org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.resolve(CachingTaskDependencyResolveContext.java:66)
    ... 83 more

Get more help at https://help.gradle.org

BUILD FAILED in 0s

答:
Can you try this: https://github.com/google/protobuf-gradle-plugin/issues/129 Upgrade your protobuf to 0.8.2 or later and have a try?
It could be caused by the Gradle 3.0 compatible issue. I run into the same problem but I resolved by downgraded the gradle to 2.6.</p>


问:
Get query string parameters url values with jQuery / Javascript (querystring)
Anyone know of a good way to write a jQuery extension to handle query string parameters? I basically want to extend the jQuery magic ($) function so I can do something like this:

```<code>$('?search').val();
</code>```

Which would give me the value "test" in the following URL: http://www.example.com/index.php?search=test.

I've seen a lot of functions that can do this in jQuery and Javascript, but I actually want to extend jQuery to work exactly as it is shown above. I'm not looking for a jQuery plugin, I'm looking for an extension to the jQuery method.

答:
Written in Vanilla Javascript    </p>

```<code>     //Get URL
     var loc = window.location.href;
     console.log(loc);
     var index = loc.indexOf("?");
     console.log(loc.substr(index+1));
     var splitted = loc.substr(index+1).split('&');
     console.log(splitted);
     var paramObj = [];
     for(var i=0;i<splitted.length;i++){
         var params = splitted[i].split('=');
         var key = params[0];
         var value = params[1];
         var obj = {
             [key] : value
         };
         paramObj.push(obj);
         }
    console.log(paramObj);
    //Loop through paramObj to get all the params in query string.
</code>```

Body:
Anyone know of a good way to write a jQuery extension to handle query string parameters? I basically want to extend the jQuery magic ($) function so I can do something like this:

$('?search').val();

Which would give me the value "test" in the following URL: http://www.example.com/index.php?search=test.

I've seen a lot of functions that can do this in jQuery and Javascript, but I actually want to extend jQuery to work exactly as it is shown above. I'm not looking for a jQuery plugin, I'm looking for an extension to the jQuery method.

Body:
Written in Vanilla Javascript

     //Get URL
     var loc = window.location.href;
     console.log(loc);
     var index = loc.indexOf("?");
     console.log(loc.substr(index+1));
     var splitted = loc.substr(index+1).split('&');
     console.log(splitted);
     var paramObj = [];
     for(var i=0;i<splitted.length;i++){
         var params = splitted[i].split('=');
         var key = params[0];
         var value = params[1];
         var obj = {
             [key] : value
         };
         paramObj.push(obj);
         }
    console.log(paramObj);
    //Loop through paramObj to get all the params in query string.


问:
Hide or remove Action Bar on specific Activity | Android
How I can remove Action Bar on specific activity not for all application, for example I have Sign Up activity and for this activity I want to remove Action Bar</p>

答: Remove Action Bar on specific Activity go to Activity java file here your Activity class extends with AppCompatActivity remove the AppCompatActivity and extends with Activity and go to xml file and select Theme NoTitleBar or go to Manifests file select your Activity and add Theme on your Activity android:theme="@android:style/Theme.NoTitleBar"/>


问:
Choose file inside webview
I create code webview in Android Studio. When try to run an application (webview apps) and click a link to download a file nothing happens. what should i do?`

```<code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("http://my-url/");
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
}
</code>```

`

答:
hope so this will be helpful for you </p>

```<code>import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import org.apache.http.util.EncodingUtils;

public class BrowserScreen extends Activity {

    private WebView webView;
    private String url = "url";

    private ValueCallback<Uri> mUploadMessage;
    private final static int FILECHOOSER_RESULTCODE = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initFields();
        setListeners();

    }

    public void initFields() {
        // TODO Auto-generated method stub

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setAllowFileAccess(true);
    }

    public void setListeners() {
        // TODO Auto-generated method stub

        webView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

                webView.loadUrl("http://my-url/");

                view.clearHistory();
            }

        });

        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {

            }

            //The undocumented magic method override
            //Eclipse will swear at you if you try to put @Override here
            // For Android 3.0+
            public void openFileChooser(ValueCallback<Uri> uploadMsg) {

                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
            }

            // For Android 3.0+
            public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("*/*");
                startActivityForResult(
                        Intent.createChooser(i, "File Browser"),
                        FILECHOOSER_RESULTCODE);
            }

            //For Android 4.1
            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            }

        });

            webView.loadUrl(url);

        final MyJavaScriptInterface myJavaScriptInterface
                = new MyJavaScriptInterface(this);
        webView.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction");
    }

    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub

        if (webView.canGoBack() == true) {
            webView.goBack();
        } else {
            super.onBackPressed();
        }
    }

    public class MyJavaScriptInterface {
        Context mContext;

        MyJavaScriptInterface(Context c) {
            mContext = c;
        }

        @JavascriptInterface
        public void showToast(String toast) {
            Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
            // webView.loadUrl("javascript:document.getElementById(\"Button3\").innerHTML = \"bye\";");
        }

        @JavascriptInterface
        public void openAndroidDialog() {
            AlertDialog.Builder myDialog
                    = new AlertDialog.Builder(BrowserScreen.this);
            myDialog.setTitle("DANGER!");
            myDialog.setMessage("You can do what you want!");
            myDialog.setPositiveButton("ON", null);
            myDialog.show();
        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent intent) {
        if (requestCode == FILECHOOSER_RESULTCODE) {
            if (null == mUploadMessage) return;
            Uri result = intent == null || resultCode != RESULT_OK ? null
                    : intent.getData();
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
    }
}
</code>```

Title: Choose file inside webview

Body:
I create code webview in Android Studio. When try to run an application (webview apps) and click a link to download a file nothing happens. what should i do?`

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("http://my-url/");
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
}

`

Body:
hope so this will be helpful for you

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import org.apache.http.util.EncodingUtils;

public class BrowserScreen extends Activity {

    private WebView webView;
    private String url = "url";

    private ValueCallback<Uri> mUploadMessage;
    private final static int FILECHOOSER_RESULTCODE = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initFields();
        setListeners();

    }

    public void initFields() {
        // TODO Auto-generated method stub

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setAllowFileAccess(true);
    }

    public void setListeners() {
        // TODO Auto-generated method stub

        webView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

                webView.loadUrl("http://my-url/");

                view.clearHistory();
            }

        });

        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {

            }

            //The undocumented magic method override
            //Eclipse will swear at you if you try to put @Override here
            // For Android 3.0+
            public void openFileChooser(ValueCallback<Uri> uploadMsg) {

                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
            }

            // For Android 3.0+
            public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("*/*");
                startActivityForResult(
                        Intent.createChooser(i, "File Browser"),
                        FILECHOOSER_RESULTCODE);
            }

            //For Android 4.1
            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
                mUploadMessage = uploadMsg;
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
                i.addCategory(Intent.CATEGORY_OPENABLE);
                i.setType("image/*");
                startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            }

        });

            webView.loadUrl(url);

        final MyJavaScriptInterface myJavaScriptInterface
                = new MyJavaScriptInterface(this);
        webView.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction");
    }

    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub

        if (webView.canGoBack() == true) {
            webView.goBack();
        } else {
            super.onBackPressed();
        }
    }

    public class MyJavaScriptInterface {
        Context mContext;

        MyJavaScriptInterface(Context c) {
            mContext = c;
        }

        @JavascriptInterface
        public void showToast(String toast) {
            Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
            // webView.loadUrl("javascript:document.getElementById(\"Button3\").innerHTML = \"bye\";");
        }

        @JavascriptInterface
        public void openAndroidDialog() {
            AlertDialog.Builder myDialog
                    = new AlertDialog.Builder(BrowserScreen.this);
            myDialog.setTitle("DANGER!");
            myDialog.setMessage("You can do what you want!");
            myDialog.setPositiveButton("ON", null);
            myDialog.show();
        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent intent) {
        if (requestCode == FILECHOOSER_RESULTCODE) {
            if (null == mUploadMessage) return;
            Uri result = intent == null || resultCode != RESULT_OK ? null
                    : intent.getData();
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
    }
}


问:
Google: Permission denied to generate login hint for target domain NOT on localhost
I am trying to create a Google sign-in and getting the error:

Permission denied to generate login hint for target domain

Before you mark this a duplicate, this is not the same as the question asked at Google sign in website Error : Permission denied to generate login hint for target domain because in that case the questioner was on localhost, whereas I am getting this error on the server.

Specifically, I have included the url of the server in the Authorized Javascript Origins, as in the following image:

and when I get the error, the request shows that the same url was sent, as in the following image:

Is there something else I should be putting in my Restrictions page? Is there any way to figure out what is going on here? Is there a log at the developer console that can tell me what is happening?

答:
To allow ip address to be used as valid javascript origin, first add an entry in your /etc/hosts file

```<code>10.0.0.1 mydevserver.com
</code>```

and then add this domain mydeveserver.com in Authorized Javascript Origins. If you are using some nonstandard port, then specify it with your domain in Authorized Javascript Origins.

Note: Remove your cache and it will work.

Body:
To allow ip address to be used as valid javascript origin, first add an entry in your /etc/hosts file

10.0.0.1 mydevserver.com

and then add this domain mydeveserver.com in Authorized Javascript Origins. If you are using some nonstandard port, then specify it with your domain in Authorized Javascript Origins.

Note: Remove your cache and it will work.


问:
Picasso is just working on one emulator
I can load my image succeed on a emulator (Android 7.0 API24)

I use Picasso version is

```<code>compile 'com.squareup.picasso:picasso:2.5.2'
</code>```

When i run project to another emulator on other computer or my android device that is Huaweb mate8(Android 7.0 API24), i can't load my image anymore, it shows error image.

I don't know why it happens like this.

Here is my imageUrl="http://192.168.22.111:2212/DB/Convention/1.jpg"
Any emulators and my android device use the same WIFI.

My code:

```<code>Picasso.with(getActivity()).load(imageUrl).centerCrop().fit()
                    .placeholder(R.drawable.button_icon_apply_128x128)
                    .error(R.drawable.app_icon_512x512)
                    .into(destImage, new com.squareup.picasso.Callback() {
                        @Override
                        public void onSuccess() {
                            Log.i(TAG, "onSuccess: TRUE");
                        }

                        @Override
                        public void onError() {
                            Log.i(TAG, "onError: TRUE");
                        }
                    });
</code>```

My imageView xml:

```<code><ImageView
            android:id="@+id/destImage"
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:scaleType="fitXY"
            android:adjustViewBounds="true"
            android:layout_gravity="center" />
</code>```

Any help would be appreciated. Thanks in advance.

答:
Does your test device was connected on internet (Or your private network)? Run web browser for check it.

Your emulator can use your PC's network, instead of using real wifi.

Load your URL With web browser in your device.

Title: Picasso is just working on one emulator

Body:
I can load my image succeed on a emulator (Android 7.0 API24)

I use Picasso version is

compile 'com.squareup.picasso:picasso:2.5.2'

When i run project to another emulator on other computer or my android device that is Huaweb mate8(Android 7.0 API24), i can't load my image anymore, it shows error image.

I don't know why it happens like this.

Here is my imageUrl="http://192.168.22.111:2212/DB/Convention/1.jpg"
Any emulators and my android device use the same WIFI.

My code:

Picasso.with(getActivity()).load(imageUrl).centerCrop().fit()
                    .placeholder(R.drawable.button_icon_apply_128x128)
                    .error(R.drawable.app_icon_512x512)
                    .into(destImage, new com.squareup.picasso.Callback() {
                        @Override
                        public void onSuccess() {
                            Log.i(TAG, "onSuccess: TRUE");
                        }

                        @Override
                        public void onError() {
                            Log.i(TAG, "onError: TRUE");
                        }
                    });

My imageView xml:

<ImageView
            android:id="@+id/destImage"
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:scaleType="fitXY"
            android:adjustViewBounds="true"
            android:layout_gravity="center" />

Any help would be appreciated. Thanks in advance.


问:
How to format specflow .feature file
This may sound silly but Is there a way format specflow .feature file? in .cs file I can do ctrl+E ctrl+D  I have to format my tables manually which is a hideous work.

I am not sure if this is related to my VS2013 setting but the Given,And and Then steps won't collapse and expand at all.  Thanks

答:
Shortcut keys to format specflow table is Shift+|(press shift and Pipe Symbol).
Place the cursor at the end of the table on Specflow, so it does format the respective table on key press of "shift And |(Pipe,Or Symbol).

Hope you will find it helpful.

Title: How to format specflow .feature file


问:
Remove everything after a character, but keep the character
Let's say I have a string that reads "45216 Walnut Avenue Mary's Bake Shop".
I want to remove everything after the word Avenue, but I would like avenue to remain. How does this work?

I've tried the following with no luck:

```<code>a <- "45216 Walnut Avenue Mary's Bake Shop"
a <- gsub("Avenue.*$", "", a)

[1] "45216 Walnut "
</code>```

答:
Probably the most direct way to do this would be by capturing "Avenue" with () and then chopping off everything that appears after it:

```<code>a <- "45216 Walnut Avenue Mary's Bake Shop"
gsub("(Avenue).*", "\\1", a)
</code>```

You'll get:

```<code>## [1] "45216 Walnut Avenue"
</code>```

Body:
Let's say I have a string that reads "45216 Walnut Avenue Mary's Bake Shop".
I want to remove everything after the word Avenue, but I would like avenue to remain. How does this work?

I've tried the following with no luck:

a <- "45216 Walnut Avenue Mary's Bake Shop"
a <- gsub("Avenue.*$", "", a)

[1] "45216 Walnut "

Body:
Probably the most direct way to do this would be by capturing "Avenue" with () and then chopping off everything that appears after it:

a <- "45216 Walnut Avenue Mary's Bake Shop"
gsub("(Avenue).*", "\\1", a)

You'll get:

## [1] "45216 Walnut Avenue"


问:
How to implement `using` in javascript?
I would like to make something like this (similar to c#):

```<code>using("content/jquery.js");

$("div").fadeOut();
</code>```

So if content/jquery.js is not on a script in the head I would like to load it and continue the execution after it loads.

Is it possible to implement this or something similar? Note: I could have more than 1 using

答:
If you know the name of the functions you'll be calling ahead of time you can use typeof to check for their presence:

```<code>if (typeof($) == 'function') {
  // Code here that uses jQuery
} else {
  // Something else here that loads the script.
}
</code>```

If you're not certain what functions you'll be using you probably want to retrieve a list of the script elements and check them.  Something more along these lines:

```<code>var scripts = document.getElementsByTagName('script');

for (var i = 0, l = scripts.length; i < l; ++i) {
  if (scripts[i].src == myVal) {
    // do something here
  } else {
    // wait for the script to load, or just leave off the else.
  }
}
</code>```

Are the two approaches I can think of off the top of my head.

Title: How to implement `using` in javascript?

Body:
I would like to make something like this (similar to c#):

using("content/jquery.js");

$("div").fadeOut();

So if content/jquery.js is not on a script in the head I would like to load it and continue the execution after it loads.

Is it possible to implement this or something similar? Note: I could have more than 1 using

Body:
If you know the name of the functions you'll be calling ahead of time you can use typeof to check for their presence:

if (typeof($) == 'function') {
  // Code here that uses jQuery
} else {
  // Something else here that loads the script.
}

If you're not certain what functions you'll be using you probably want to retrieve a list of the script elements and check them.  Something more along these lines:

var scripts = document.getElementsByTagName('script');

for (var i = 0, l = scripts.length; i < l; ++i) {
  if (scripts[i].src == myVal) {
    // do something here
  } else {
    // wait for the script to load, or just leave off the else.
  }
}

Are the two approaches I can think of off the top of my head.


问:
Searching particular string in a string array of split operations
I have a string

```<code>str = "Abc=1,gdf=1,ghj=1,pqr=1"
</code>```

Now I to increment the value of pqr=1 to pqr2 whenever prq will come it will increment the value by 1.  So I decided to start by Spitting this string at every ","  so that a part of spilited string array will contain pqr=1 and then I can perform my operation of incrementing.

Code is as follows

```<code>String []  parts=str.split("=");
</code>```

This gives parts of string which contains pqr at index 3 but it is not necessary everytime pqr will be at index 3 so I want to make I it generic.  For that I am trying to do as follows:

```<code>if(Arrays. asList(parts). contains("pqr") {
    // Do my other split operation
}
</code>```

But I am not able to make it generic by this.  I am not getting any error but code is not going inside if statement.  Please suggest how to do it.

答:
Is this what you are looking for? I am doing my best with the code provided.

```<code>    public class Splitter {

    public static void main(String[] args) {

        String str = "Abc=1,gdf=1,ghj=1,pqr=1";

        String[] strSplit = str.split(",");

        int commaSplitCount = strSplit.length;

        for (int s = 0; s < commaSplitCount; s++) {

            String[] sSplit = strSplit[s].split("=");

            int equalsSplitCount = sSplit.length;

            if (equalsSplitCount > 0) {

                for (int sParts = 0; sParts < equalsSplitCount; sParts++) {
                    if (sParts == 0) {
                        if (sSplit[sParts].contains("pqr")) {

                            System.out.println("do something >> " + sSplit[sParts]);

                        } else {
                            System.out.println("do something else >> " + sSplit[sParts]);
                        }
                    }
                }
            }

        }

    }

}
</code>```

If you do something different with each, you can use a switch.

The output is:

```<code>do something else >> Abc
do something else >> gdf
do something else >> ghj
do something >> pqr
</code>```

Whatever it is you want to do to pqr you can do at the sout so something.

Body:
I have a string

str = "Abc=1,gdf=1,ghj=1,pqr=1"

Now I to increment the value of pqr=1 to pqr2 whenever prq will come it will increment the value by 1.  So I decided to start by Spitting this string at every ","  so that a part of spilited string array will contain pqr=1 and then I can perform my operation of incrementing.

Code is as follows

String []  parts=str.split("=");

This gives parts of string which contains pqr at index 3 but it is not necessary everytime pqr will be at index 3 so I want to make I it generic.  For that I am trying to do as follows:

if(Arrays. asList(parts). contains("pqr") {
    // Do my other split operation
}

But I am not able to make it generic by this.  I am not getting any error but code is not going inside if statement.  Please suggest how to do it.

Body:
Is this what you are looking for? I am doing my best with the code provided.

    public class Splitter {

    public static void main(String[] args) {

        String str = "Abc=1,gdf=1,ghj=1,pqr=1";

        String[] strSplit = str.split(",");

        int commaSplitCount = strSplit.length;

        for (int s = 0; s < commaSplitCount; s++) {

            String[] sSplit = strSplit[s].split("=");

            int equalsSplitCount = sSplit.length;

            if (equalsSplitCount > 0) {

                for (int sParts = 0; sParts < equalsSplitCount; sParts++) {
                    if (sParts == 0) {
                        if (sSplit[sParts].contains("pqr")) {

                            System.out.println("do something >> " + sSplit[sParts]);

                        } else {
                            System.out.println("do something else >> " + sSplit[sParts]);
                        }
                    }
                }
            }

        }

    }

}

If you do something different with each, you can use a switch.

The output is:

do something else >> Abc
do something else >> gdf
do something else >> ghj
do something >> pqr

Whatever it is you want to do to pqr you can do at the sout so something.


问:
Star-rating with css
so I have these radio buttons that form a star-rating component in reactjs, when I hover over the stars they paint in yellow but when I click in one of them and hover out of the stars the color doesn't stay and the gray color come back in all of them.

Here is the js file:

```<code>    render(){
    return (
      <div className="star-rating">
        <input id="star-5" type="radio" name="rating" value="star-5"></input>
        <label for="star-5" title="5 stars">
            <i className="active fa fa-star" aria-hidden="true"></i>
        </label>
        <input id="star-4" type="radio" name="rating" value="star-4"></input>
        <label for="star-4" title="4 stars">
            <i className="active fa fa-star" aria-hidden="true"></i>
        </label>
        <input id="star-3" type="radio" name="rating" value="star-3"></input>
        <label for="star-3" title="3 stars">
            <i className="active fa fa-star" aria-hidden="true"></i>
        </label>
        <input id="star-2" type="radio" name="rating" value="star-2"></input>
        <label for="star-2" title="2 stars">
            <i className="active fa fa-star" aria-hidden="true"></i>
        </label>
        <input id="star-1" type="radio" name="rating" value="star-1"></input>
        <label for="star-1" title="1 star">
            <i className="active fa fa-star" aria-hidden="true"></i>
        </label>
      </div>
    );
}
</code>```

and the css:

.star-rating {
    direction: rtl;
    display: inline-block;
    padding: 20px
}

.star-rating input[type=radio] {
    display: none
}

.star-rating label {
    color: #bbb;
    font-size: 50px;
    padding: 0;
    cursor: pointer;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input[type=radio]:checked ~ label {
    color: #f2b600
}```

Any help?

答:
try this from James Barnett

@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);

fieldset, label { margin: 0; padding: 0; }
body{ margin: 20px; }
h1 { font-size: 1.5em; margin: 10px; }

/****** Style Star Rating Widget *****/

.rating {
  border: none;
  float: left;
}

.rating > input { display: none; }
.rating > label:before {
  margin: 5px;
  font-size: 1.25em;
  font-family: FontAwesome;
  display: inline-block;
  content: "\f005";
}

.rating > .half:before {
  content: "\f089";
  position: absolute;
}

.rating > label {
  color: #ddd;
 float: right;
}

/***** CSS Magic to Highlight Stars on Hover *****/

.rating > input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) > label:hover, /* hover current star */
.rating:not(:checked) > label:hover ~ label { color: #FFD700;  } /* hover previous stars in list */

.rating > input:checked + label:hover, /* hover current star when changing rating */
.rating > input:checked ~ label:hover,
.rating > label:hover ~ input:checked ~ label, /* lighten current selection */
.rating > input:checked ~ label:hover ~ label { color: #FFED85;  } ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><fieldset class="rating">
    <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
    <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
    <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
    <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
    <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
    <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
    <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
    <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
    <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
    <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
</fieldset></code>```

Title: Star-rating with css

Body:
so I have these radio buttons that form a star-rating component in reactjs, when I hover over the stars they paint in yellow but when I click in one of them and hover out of the stars the color doesn't stay and the gray color come back in all of them.

Here is the js file:

    render(){
    return (

        <input id="star-5" type="radio" name="rating" value="star-5"></input>

        <input id="star-4" type="radio" name="rating" value="star-4"></input>

        <input id="star-3" type="radio" name="rating" value="star-3"></input>

        <input id="star-2" type="radio" name="rating" value="star-2"></input>

        <input id="star-1" type="radio" name="rating" value="star-1"></input>

    );
}

and the css:

.star-rating {
    direction: rtl;
    display: inline-block;
    padding: 20px
}

.star-rating input[type=radio] {
    display: none
}

.star-rating label {
    color: #bbb;
    font-size: 50px;
    padding: 0;
    cursor: pointer;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input[type=radio]:checked ~ label {
    color: #f2b600
}

Any help?

Body:
try this from James Barnett

@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);

fieldset, label { margin: 0; padding: 0; }
body{ margin: 20px; }
h1 { font-size: 1.5em; margin: 10px; }

/****** Style Star Rating Widget *****/

.rating {
  border: none;
  float: left;
}

.rating > input { display: none; }
.rating > label:before {
  margin: 5px;
  font-size: 1.25em;
  font-family: FontAwesome;
  display: inline-block;
  content: "\f005";
}

.rating > .half:before {
  content: "\f089";
  position: absolute;
}

.rating > label {
  color: #ddd;
 float: right;
}

/***** CSS Magic to Highlight Stars on Hover *****/

.rating > input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) > label:hover, /* hover current star */
.rating:not(:checked) > label:hover ~ label { color: #FFD700;  } /* hover previous stars in list */

.rating > input:checked + label:hover, /* hover current star when changing rating */
.rating > input:checked ~ label:hover,
.rating > label:hover ~ input:checked ~ label, /* lighten current selection */
.rating > input:checked ~ label:hover ~ label { color: #FFED85;  }

<fieldset class="rating">
    <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
    <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
    <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
    <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
    <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
    <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
    <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
    <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
    <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
    <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
</fieldset>