问:
Click one div in order to open only it's children and not other with same class
So I tried obviously using $('this .classname') but it toggle closes the whole div.
I'm trying to have each div (image is placed) be clicked and only it's ul be opened.

HTML

```<code><div class="col-md-12 col-xs-12">

    <div class="recipePicContainer">
        <div id="checkBoxes">
                <li class="recipe" id="recipe01"><label>Cocktail</label></li>
                       <ul class="recipes">
                           <li class="ingredient"><input type="checkbox"> ingredient 1</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 2</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 3</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 4</li>
                            <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
                       </ul>
                </div>
            </div>

        <div class="recipePicContainer">
            <div class="checkBoxes">
                <li class="recipe" id="recipe02"><label>Main Dish</label></li>
                       <ul class="recipes">
                           <li class="ingredient"><input type="checkbox"> ingredient 1</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 2</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 3</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 4</li>
                            <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
                       </ul>
                </div>
            </div>

        <div class="recipePicContainer">
            <div class="checkBoxes">
                <li class="recipe" id="recipe03"><label>Dessert</label></li>
                       <ul class="recipes">
                           <li class="ingredient"><input type="checkbox"> ingredient 1</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 2</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 3</li>
                           <li class="ingredient"><input type="checkbox"> ingredient 4</li>
                            <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
                       </ul>
                </div>
            </div>

</div>
</code>```

JS

```<code>var main = function() {
    $(document).ready(function () {
        $('ul').hide();
        $('.recipe').click(function () {
            $('.recipes').toggle("slow").toggleClass('selected');
        });
    });
};
$(document).ready(main);
</code>```

答:
Here you go with the solution https://jsfiddle.net/jzwjh5jp/3/

var main = function() {
    $(document).ready(function () {
        $('.recipes').hide();
        $('.recipe').click(function () {
            $(this).siblings().toggle("slow").toggleClass('selected');
        });
    });
};
$(document).ready(main);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.recipes {
  padding-left:50px;
}</code>```

Cocktail

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Main Dish

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Dessert

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

```

Body:
So I tried obviously using $('this .classname') but it toggle closes the whole div.
I'm trying to have each div (image is placed) be clicked and only it's ul be opened.

HTML

Cocktail

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Main Dish

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Dessert

<input type="checkbox"> ingredient 1

<input type="checkbox"> ingredient 2

<input type="checkbox"> ingredient 3

<input type="checkbox"> ingredient 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

JS

var main = function() {
    $(document).ready(function () {
        $('ul').hide();
        $('.recipe').click(function () {
            $('.recipes').toggle("slow").toggleClass('selected');
        });
    });
};
$(document).ready(main);

Body:
Here you go with the solution https://jsfiddle.net/jzwjh5jp/3/

var main = function() {
    $(document).ready(function () {
        $('.recipes').hide();
        $('.recipe').click(function () {
            $(this).siblings().toggle("slow").toggleClass('selected');
        });
    });
};
$(document).ready(main);

.recipes {
  padding-left:50px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-12 col-xs-12">
  <div class="recipePicContainer">
    <div id="checkBoxes">
    <ul class="recipe" id="recipe01"><li>Cocktail</li></ul>
    <ul class="recipes">
      <li class="ingredient"><input type="checkbox"> ingredient 1</li>
      <li class="ingredient"><input type="checkbox"> ingredient 2</li>
      <li class="ingredient"><input type="checkbox"> ingredient 3</li>
      <li class="ingredient"><input type="checkbox"> ingredient 4</li>
      <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
    </ul>
    </div>
  </div>

  <div class="recipePicContainer">
     <div class="checkBoxes">
     <ul class="recipe" id="recipe02"><li>Main Dish</li></ul>
     <ul class="recipes">
        <li class="ingredient"><input type="checkbox"> ingredient 1</li>
        <li class="ingredient"><input type="checkbox"> ingredient 2</li>
        <li class="ingredient"><input type="checkbox"> ingredient 3</li>
        <li class="ingredient"><input type="checkbox"> ingredient 4</li>
        <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
      </ul>
      </div>
    </div>

  <div class="recipePicContainer">
    <div class="checkBoxes">
      <ul class="recipe" id="recipe03"><li>Dessert</li></ul>
       <ul class="recipes">
           <li class="ingredient"><input type="checkbox"> ingredient 1</li>
           <li class="ingredient"><input type="checkbox"> ingredient 2</li>
           <li class="ingredient"><input type="checkbox"> ingredient 3</li>
           <li class="ingredient"><input type="checkbox"> ingredient 4</li>
            <li class="instructions">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
       </ul>
    </div>
  </div>
</div>


来源: stackexchange

问:
How can I create an .mo file for Wordpress
I have some .po files for Wordpress and i want to create .mo files.

How can i do this?

答: Generally, you could run the .po file through a tool like pocompile. Some editors are a bit more comfortable, for example, Poedit can compile .mo files automatically. :)</p>

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
cannot print "hello world" on the browser using php language
I'm wondering why I cannot display the simple "hello world" using php language.

This is how my code looks like:

```<code><?
 echo "Hello world";
?>
</code>```

and this is how the output come out in the browser, nothing display:

答:
You need to make sure following things for executing php file.

Php tag should be properly open and close <?php ... ?>

You xampp server is properly running.

You are accessing file by putting correct path.

Body:
I'm wondering why I cannot display the simple "hello world" using php language.

This is how my code looks like:

<?
 echo "Hello world";
?>

and this is how the output come out in the browser, nothing display:


问:
python print all function calls to know the script flow
How can I print every function/method call ?
I have tried to use : python -m trace --trace but it prints also the function inner code... I just want functions names that were called.
using traceback in code prints the last function called before calling the command itself, and the code contains many classes...

答:
here is the code with name player.py.

```<code># player.py
def foo():
    pass
def bar():
    foo()
def car():
    bar()
    pass
car()
</code>```

executed the command from the terminal like $python -m trace -T player.py and it gives me the following output. you can also use for --trackcalls instead of -T for the same output. And that command Display the calling relationships exposed by running the program.

```<code>calling relationships:

*** /usr/lib/python2.7/trace.py ***
    trace.Trace.runctx -> trace._unsettrace
  --> player.py
    trace.Trace.runctx -> player.<module>

*** player.py ***
    player.<module> -> player.car
    player.bar -> player.foo
    player.car -> player.bar
</code>```

Hope this will help.

Update 1:

the above command display the function's relationship.

For tracing the function we can use traceback module. In this module traceback.print_stack() print the function depending on the execution. But we have to keep in mind that in which method we write the traceback.print_stack() it will only print the trace of that function. I will give you an example.

```<code>import traceback
def foo():
    car()
    pass
def bar():
    foo()
def car():
    traceback.print_stack()
    pass
bar()
</code>```

and if we run this we can see the following output.

```<code>File "D:/python_practice36/player.py", line 10, in <module>
bar()
File "D:/python_practice36/player.py", line 6, in bar
foo()
File "D:/python_practice36/player.py", line 3, in foo
car()
File "D:/python_practice36/player.py", line 8, in car
traceback.print_stack()
</code>```

if we call the traceback.print_stack() in foo() then we can see the traceback upto foo.

```<code>import traceback
def foo():
    car()
    traceback.print_stack()
    pass
def bar():
    foo()
def car():
    pass
bar()
</code>```

and the output is

```<code>File "D:/python_practice36/player.py", line 10, in <module>
bar()
File "D:/python_practice36/player.py", line 7, in bar
foo()
File "D:/python_practice36/player.py", line 4, in foo
traceback.print_stack()
</code>```

Body:
here is the code with name player.py.

# player.py
def foo():
    pass
def bar():
    foo()
def car():
    bar()
    pass
car()

executed the command from the terminal like $python -m trace -T player.py and it gives me the following output. you can also use for --trackcalls instead of -T for the same output. And that command Display the calling relationships exposed by running the program.

calling relationships:

*** /usr/lib/python2.7/trace.py ***
    trace.Trace.runctx -> trace._unsettrace
  --> player.py
    trace.Trace.runctx -> player.<module>

*** player.py ***
    player.<module> -> player.car
    player.bar -> player.foo
    player.car -> player.bar

Hope this will help.

Update 1:

the above command display the function's relationship.

For tracing the function we can use traceback module. In this module traceback.print_stack() print the function depending on the execution. But we have to keep in mind that in which method we write the traceback.print_stack() it will only print the trace of that function. I will give you an example.

import traceback
def foo():
    car()
    pass
def bar():
    foo()
def car():
    traceback.print_stack()
    pass
bar()

and if we run this we can see the following output.

File "D:/python_practice36/player.py", line 10, in <module>
bar()
File "D:/python_practice36/player.py", line 6, in bar
foo()
File "D:/python_practice36/player.py", line 3, in foo
car()
File "D:/python_practice36/player.py", line 8, in car
traceback.print_stack()

if we call the traceback.print_stack() in foo() then we can see the traceback upto foo.

import traceback
def foo():
    car()
    traceback.print_stack()
    pass
def bar():
    foo()
def car():
    pass
bar()

and the output is

File "D:/python_practice36/player.py", line 10, in <module>
bar()
File "D:/python_practice36/player.py", line 7, in bar
foo()
File "D:/python_practice36/player.py", line 4, in foo
traceback.print_stack()


问:
How can I validate an email address in JavaScript?
I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?</p>

ContentLicense: CC BY-SA 4.0

LastEditorDisplayName: Vincent Robert

Body:
ES6 sample

const validateEmail=(email)=> /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email);


问:
Python 3.6 in Visual Studio 2017 How to Run Program in the Interactive Shell
I downloaded and installed Visual Studio along with Anaconda to get access to all of the packages that come pre installed with Anaconda. I am trying to figure out how to run code such that it runs in the interactive shell. Right now when I hit F5 an Anaconda 3 cmd line window comes up with the prompt "Press any key to continue..." comes up.  My question is: how can I make it so that when I hit F5 my code is executed in the interactive Python shell much like it does on the basic IDLE that comes with Python.

This seems like a question that a simple Google Search could fix, but for some reason I cannot find the answer. I've done some google searching, and I watched the Visual Studio python official Microsoft series about it. One of the videos touched on using the interactive shell, but even in the video, when he clicked the Start (Run) button, the code ran in what looked like the command line.

I have used IDLE in the past, and now I think it is time to make the change to a bigger IDE. I love the code completion and templates of visual studio, and I can't wait to solve this (noob) question.

Thanks

答:
I am struggling with this as well. There is a Visual Studio Shell command execute file in Python interactive which is bound to Shift+Alt+F5 by default.

This works: if the focus is in a code window then the current file is executed. If the focus is in the Solution Explorer window, the file selected as "Startup item" is executed. There seems to be a glitch however: Some import statements from the specific file which work fine on the standard Ctrl+F5 will fail on Shift+Alt+F5. I need to figure out why this is the case and will report here.

EDIT: Once in the interactive windows, change the working directory to the folder containing the project: os.chdir etc. Then import your-filename works flawlessly. So I assume that there is some problem with selecting the working directory while executing Shift+Alt+F5.


问:
How can I limit a TextView's size without using 'maxwidth'?
I've been trying to create a layout for a RecyclerView item, but I'm, having trouble getting there. I'll try my best to explain what I want and what I've gotten so far.
My design has a Button, a TextView, a couple of ImageViews and a LinearLayout with some ImageViews inside it. The image below explains it well.

The gray elements have fixed width and position (the button to the left and the LL with ivs to the right).

The green and red ivs have fixed width but should be positioned to the right of the blue tv, UNLESS the blue tv is too big and tries to push them on top of the gray LL to the right. In that case, the text is cut short and an ellipsis is added at the end.

The green and red ivs may or may not be visible (visibility="true" or "gone"). The blue tv should occupy their spaces if they're "gone" (and if there's enough text content in it to do so).

I've gotten sort of close to what I want: the blue tv and the red and green ivs are inside a LinearLayout with a gravity=left attribute. The blue tv has the ellipsis=end attribute. The one thing that's still wrong is the blue tv has to have a maxwidth attribute so it does not push the green/red ivs over the gray LinearLayout to the right. So, when the red or green ivs are "gone", there's an empty space to the right (before the gray LinearLayout) since the blue tv's maxwidth limits it.

Is there a way to achieve this? How can I eliminate the maxwidth attribute and still prevent the textview content from pushing the green and red ivs too far to the right and overruning the gray LinearLayout?

I don't have any experience with ConstraintLayout (and am a beginner in android development). Is there a way to achieve this using it?

Here's the code I have so far.

```<code><LinearLayout
    android:id="@+id/leiaute"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <Button
        android:id="@+id/quad_done_undone"
        android:layout_width="17.6dp"
        android:layout_height="16dp"
        android:layout_marginLeft="14dp"
        android:src="@drawable/circulo_unchecked"/>

    <LinearLayout
        android:id="@+id/itemClickableArea"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:layout_weight="1"
        android:gravity="left|center_vertical"
        android:orientation="horizontal"
        android:background="?attr/selectableItemBackground">

        <TextView
            android:id="@+id/titulo"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:ellipsize="end"
            android:fontFamily="sans-serif"
            android:gravity="left|center_vertical"
            android:maxLines="1"
            android:maxWidth="210dp"
            android:text="Lorem Ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
            android:textColor="@color/preto"
            android:textSize="13sp"
            android:visibility="visible"/>

        <ImageButton
            android:id="@+id/descricao"
            android:layout_width="16dp"
            android:layout_height="13.5dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="1dp"
            android:background="@drawable/description_icon"/>

        <ImageView
            android:id="@+id/play"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:src="@drawable/play"
            android:tint="@color/cinza3"
            android:visibility="visible"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="36dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="6dp"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical">

        <TextView
            android:id="@+id/data_hora"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:maxLines="2"
            android:textColor="@color/textList"
            android:textSize="12sp"
            tools:text="31 mar\n9:42"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/repeat"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:layout_marginRight="2dp"
                android:src="@drawable/repeat"
                android:tint="@color/iconesList"/>

            <ImageView
                android:id="@+id/locale"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:src="@drawable/locale"
                android:tint="@color/iconesList"/>

            <ImageView
                android:id="@+id/alarm"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:layout_marginLeft="2dp"
                android:src="@drawable/alarm"
                android:tint="@color/iconesList"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
</code>```

答:
Here is a solution with a nested LinearLayout. I have removed unnecessary parts of your code to make the answer look more clear.</p>

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            tools:ignore="UselessParent">

            <Button
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#cdcdcd" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#2d94dd"
                android:ellipsize="end"
                android:lines="1"
                android:text="Stack Overflow" />

            <ImageButton
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#00c627" />

            <ImageView
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#bf0e0e" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:background="#cdcdcd" />

</LinearLayout>
</code>```

Body:
I've been trying to create a layout for a RecyclerView item, but I'm, having trouble getting there. I'll try my best to explain what I want and what I've gotten so far.
My design has a Button, a TextView, a couple of ImageViews and a LinearLayout with some ImageViews inside it. The image below explains it well.

The gray elements have fixed width and position (the button to the left and the LL with ivs to the right).

The green and red ivs have fixed width but should be positioned to the right of the blue tv, UNLESS the blue tv is too big and tries to push them on top of the gray LL to the right. In that case, the text is cut short and an ellipsis is added at the end.

The green and red ivs may or may not be visible (visibility="true" or "gone"). The blue tv should occupy their spaces if they're "gone" (and if there's enough text content in it to do so).

I've gotten sort of close to what I want: the blue tv and the red and green ivs are inside a LinearLayout with a gravity=left attribute. The blue tv has the ellipsis=end attribute. The one thing that's still wrong is the blue tv has to have a maxwidth attribute so it does not push the green/red ivs over the gray LinearLayout to the right. So, when the red or green ivs are "gone", there's an empty space to the right (before the gray LinearLayout) since the blue tv's maxwidth limits it.

Is there a way to achieve this? How can I eliminate the maxwidth attribute and still prevent the textview content from pushing the green and red ivs too far to the right and overruning the gray LinearLayout?

I don't have any experience with ConstraintLayout (and am a beginner in android development). Is there a way to achieve this using it?

Here's the code I have so far.

<LinearLayout
    android:id="@+id/leiaute"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <Button
        android:id="@+id/quad_done_undone"
        android:layout_width="17.6dp"
        android:layout_height="16dp"
        android:layout_marginLeft="14dp"
        android:src="@drawable/circulo_unchecked"/>

    <LinearLayout
        android:id="@+id/itemClickableArea"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:layout_weight="1"
        android:gravity="left|center_vertical"
        android:orientation="horizontal"
        android:background="?attr/selectableItemBackground">

        <TextView
            android:id="@+id/titulo"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:ellipsize="end"
            android:fontFamily="sans-serif"
            android:gravity="left|center_vertical"
            android:maxLines="1"
            android:maxWidth="210dp"
            android:text="Lorem Ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
            android:textColor="@color/preto"
            android:textSize="13sp"
            android:visibility="visible"/>

        <ImageButton
            android:id="@+id/descricao"
            android:layout_width="16dp"
            android:layout_height="13.5dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="1dp"
            android:background="@drawable/description_icon"/>

        <ImageView
            android:id="@+id/play"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:src="@drawable/play"
            android:tint="@color/cinza3"
            android:visibility="visible"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="36dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="6dp"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical">

        <TextView
            android:id="@+id/data_hora"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:maxLines="2"
            android:textColor="@color/textList"
            android:textSize="12sp"
            tools:text="31 mar\n9:42"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:gravity="center_horizontal|center_vertical"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/repeat"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:layout_marginRight="2dp"
                android:src="@drawable/repeat"
                android:tint="@color/iconesList"/>

            <ImageView
                android:id="@+id/locale"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:src="@drawable/locale"
                android:tint="@color/iconesList"/>

            <ImageView
                android:id="@+id/alarm"
                android:layout_width="10dp"
                android:layout_height="10dp"
                android:layout_marginLeft="2dp"
                android:src="@drawable/alarm"
                android:tint="@color/iconesList"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Body:
Here is a solution with a nested LinearLayout. I have removed unnecessary parts of your code to make the answer look more clear.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            tools:ignore="UselessParent">

            <Button
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#cdcdcd" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#2d94dd"
                android:ellipsize="end"
                android:lines="1"
                android:text="Stack Overflow" />

            <ImageButton
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#00c627" />

            <ImageView
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:background="#bf0e0e" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:background="#cdcdcd" />

</LinearLayout>


问:
Implement Open Id login
I am curious to know how can i add the Open ID login to my website, like the one this site (stackoverflow.com) is using.

My intention is to enable users to login into my site, without registration. So if they just have an account at popular sites like google, yahoo or facebook, they must be able to login to my website.

Can anyone suggest me a good and free solution ?

答:
In stackoverflow here are answer

How to use open id as login system

How do I implement OpenID in my web application?

Title: Implement Open Id login


问:
How to submit a form with Ajax, then display the form information with an alert?
I want to send a form ,then an alert shows the information inside the form.I want to show the alert this way : your FirstName is Mickey and LastName is Mouse!</p>

```<code><!DOCTYPE html>
<html>
<head>
<script
    src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
    $("button").click(function(){

        data:$("form").serialize();
        alert(data);
    });
});
</script>
</head>
<body>

<form action="">
  First name: <input type="text" name="FirstName" value="Mickey"><br>
  Last name: <input type="text" name="LastName" value="Mouse"><br>
</form>

<button>submit</button>

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

答:
```<code>    $.ajax({
      type: "POST",
      url: "ajaxform.php", // url that the data need to go
      data: $("form").serialize(),
      success: function(data) {
          if (data) {
              alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())
          }

      }
  });
</code>```

try this if you want to use values in the data object then it will depend on the object. Also you need to put the submit buton inside the form as well

$(document).ready(function(){

    $("form").submit(function(){
        alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())// remove this alert when ajax code is working. it will not work here in the fiddle
        $.ajax({
      type: "POST",
      url: "ajaxform.php", // url that the data need to go
      data: $("form").serialize(),
      success: function(data) {
          if (data) {
              alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())
          }

      }
  });
        return false;
    });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<script
    src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>

</head>
<body>

<form id="form" method="post" action="">
  First name: <input type="text" name="FirstName" value="Mickey"><br>
  Last name: <input type="text" name="LastName" value="Mouse"><br>
  <input type="submit">
</form>

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

Body:
I want to send a form ,then an alert shows the information inside the form.I want to show the alert this way : your FirstName is Mickey and LastName is Mouse!

<!DOCTYPE html>

<form action="">
  First name: <input type="text" name="FirstName" value="Mickey">

  Last name: <input type="text" name="LastName" value="Mouse">

</form>

<button>submit</button>

Body:
    $.ajax({
      type: "POST",
      url: "ajaxform.php", // url that the data need to go
      data: $("form").serialize(),
      success: function(data) {
          if (data) {
              alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())
          }

      }
  });

try this if you want to use values in the data object then it will depend on the object. Also you need to put the submit buton inside the form as well

$(document).ready(function(){

    $("form").submit(function(){
        alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())// remove this alert when ajax code is working. it will not work here in the fiddle
        $.ajax({
      type: "POST",
      url: "ajaxform.php", // url that the data need to go
      data: $("form").serialize(),
      success: function(data) {
          if (data) {
              alert("your first name is: " + $('input[name=FirstName]').val() + " Last name is: " + $('input[name=LastName]').val())
          }

      }
  });
        return false;
    });

});

<!DOCTYPE html>
<html>
<head>
<script
    src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>

</head>
<body>

<form id="form" method="post" action="">
  First name: <input type="text" name="FirstName" value="Mickey"><br>
  Last name: <input type="text" name="LastName" value="Mouse"><br>
  <input type="submit">
</form>

</body>
</html>


问:
position:fixed does not work on android
I am building a responsive website using a modified 960 grid:

```<code>@media only screen and
(min-width: 720px) and (max-width: 959px){

.container_12{
  margin-left: auto;
  margin-right: auto;
  width: 720px;
}
}
</code>```

and a navigation bar that uses position:fixed to lock itself to the top of the page.

```<code>.nav-band{
    width: 100%;
    font-weight: bold;
    position: fixed;
    z-index: 3;
    overflow: hidden;
    background-image:url('../img/trans_black.png');
    padding: 2px;
}
</code>```

This works fine in most cases, but it breaks on my android tablet.  The page loads and works fine, but when I rotate the tablet (which changes all tags with .container_12 from width:720px to width:480px) the nav bar either disappears or gets locked in an odd place, half way down the page.  How can I fix this?  The site also has an image that appears behind the nav bar within .header-band:

```<code>.header-band{
    background-image:url('../img/header_band3.png');
    background-repeat:repeat-x;
    background-position:top;
    height: 400px;
    background-color: #050505;
    position: fixed;
    z-index: 1;
}

<div class='pageband nav-band'>
<ul class='horizontal-list'>
<li class='nav-item active'>
<a href="http://...">Home</a>
</li>
...
</ul>
</div>
<div class='pageband header-band'> </div>
<div class='pageband core-band'>
<div class='pageband logo-band '>
<div class='container_12'>
...
</code>```

答:
Thanks for your help on this frustrating issue.

position: fixed; initially failed on my android and desktop devices.
removing position: relative; from the fixed element container fixed the problem on the desktop but not the android (Galaxy Note 5)
Adding
-webkit-backface-visibility: hidden; to the element did not work for android either but did cause some interesting flickering and position changes...

adding display: block; to the element's container fixed the positioning on the android and it still works on the desktop.

Good stuff looks like this
css:

```<code>body {
  background-image: url("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");
  background-repeat: repeat-y;
  display: block;
  height: 200vh;
  overflow-y: scroll;
  width: 100vh;
}

#fixed-red-box {
  position: fixed;
  top: 6%;
  right: 4%;
  -webkit-backface-visibility: hidden;
  height: 5vh;
  width: 10vw;
  border: 1vw solid red;
  z-index: 300;
  }

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-
       scale=1"/>version=5.1"/>
  </head>
  <body>
    <div id="fixed-red-box"></div>
  </body>
</html>
</code>```

took a month to find this fix.  Not a coder but do some coding hope this may help someone else with this problem.

Title: position:fixed does not work on android

Body:
I am building a responsive website using a modified 960 grid:

@media only screen and
(min-width: 720px) and (max-width: 959px){

.container_12{
  margin-left: auto;
  margin-right: auto;
  width: 720px;
}
}

and a navigation bar that uses position:fixed to lock itself to the top of the page.

.nav-band{
    width: 100%;
    font-weight: bold;
    position: fixed;
    z-index: 3;
    overflow: hidden;
    background-image:url('../img/trans_black.png');
    padding: 2px;
}

This works fine in most cases, but it breaks on my android tablet.  The page loads and works fine, but when I rotate the tablet (which changes all tags with .container_12 from width:720px to width:480px) the nav bar either disappears or gets locked in an odd place, half way down the page.  How can I fix this?  The site also has an image that appears behind the nav bar within .header-band:

.header-band{
    background-image:url('../img/header_band3.png');
    background-repeat:repeat-x;
    background-position:top;
    height: 400px;
    background-color: #050505;
    position: fixed;
    z-index: 1;
}

Home

...

...

Body:
Thanks for your help on this frustrating issue.

position: fixed; initially failed on my android and desktop devices.
removing position: relative; from the fixed element container fixed the problem on the desktop but not the android (Galaxy Note 5)
Adding
-webkit-backface-visibility: hidden; to the element did not work for android either but did cause some interesting flickering and position changes...

adding display: block; to the element's container fixed the positioning on the android and it still works on the desktop.

Good stuff looks like this
css:

body {
  background-image: url("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");
  background-repeat: repeat-y;
  display: block;
  height: 200vh;
  overflow-y: scroll;
  width: 100vh;
}

#fixed-red-box {
  position: fixed;
  top: 6%;
  right: 4%;
  -webkit-backface-visibility: hidden;
  height: 5vh;
  width: 10vw;
  border: 1vw solid red;
  z-index: 300;
  }

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-
       scale=1"/>version=5.1"/>
  </head>
  <body>
    <div id="fixed-red-box"></div>
  </body>
</html>

took a month to find this fix.  Not a coder but do some coding hope this may help someone else with this problem.


问:
Custom View inflating error
I have a simple custom View:

```<code>public class ScrollDisabledViewPager extends ViewPager {

    public ScrollDisabledViewPager(Context context) {
        super(context);
    }

    public ScrollDisabledViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return false;
    }

}
</code>```

When I put this View in my XML layout, it doesn't inflate:

XML:

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.lol.firebase.ui.SignUpActivity">

    <com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_dots"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:tabGravity="center"
        app:tabIndicatorHeight="0dp"
        app:tabBackground="@drawable/tab_indicator_selector" />

    <Button
        android:id="@+id/btn_back"
        android:text="@string/back"
        android:textColor="@color/colorPrimaryLight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:drawableLeft="@drawable/ic_back"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:visibility="gone" />

    <Button
        android:id="@+id/btn_next_or_finish"
        android:text="@string/next"
        android:textColor="@color/colorPrimaryLight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:drawableRight="@drawable/ic_next"
        style="@style/Base.Widget.AppCompat.Button.Borderless" />

</RelativeLayout>
</code>```

Stacktrace:

```<code> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lol.firebase/com.lol.firebase.ui.SignUpActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2660)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                       Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
                                                                          at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                          at com.lol.firebase.ui.SignUpActivity.onCreate(SignUpActivity.java:29)
                                                                          at android.app.Activity.performCreate(Activity.java:6117)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2613)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                       Caused by: java.lang.ClassNotFoundException: Didn't find class "com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager" on path: DexPathList[[zip file "/data/app/com.lol.firebase-1/base.apk", zip file "/data/app/com.lol.firebase-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lol.firebase-1/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:577)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:749)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
                                                                          at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                          at com.lol.firebase.ui.SignUpActivity.onCreate(SignUpActivity.java:29)
                                                                          at android.app.Activity.performCreate(Activity.java:6117)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2613)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                        Suppressed: java.lang.ClassNotFoundException: com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at java.lang.Class.classForName(Native Method)
                                                                          at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                          at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                ... 23 more
                                                                       Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
</code>```

The Stacktrace shows a ClassNotFound Exception, but I don't understand why: the class is public, and I have both constructors.

答:
Based on public class ScrollDisabledViewPager, I'm guessing that's not a nested class of SignUpActivity.java

But yet your error seems to be referring to it as one.

com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager

You can try to move the class into the com.lol.firebase.ui  package, if not there already, but the XML must match package + "." + className

Title: Custom View inflating error

Body:
I have a simple custom View:

public class ScrollDisabledViewPager extends ViewPager {

    public ScrollDisabledViewPager(Context context) {
        super(context);
    }

    public ScrollDisabledViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return false;
    }

}

When I put this View in my XML layout, it doesn't inflate:

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.lol.firebase.ui.SignUpActivity">

    <com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_dots"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:tabGravity="center"
        app:tabIndicatorHeight="0dp"
        app:tabBackground="@drawable/tab_indicator_selector" />

    <Button
        android:id="@+id/btn_back"
        android:text="@string/back"
        android:textColor="@color/colorPrimaryLight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:drawableLeft="@drawable/ic_back"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:visibility="gone" />

    <Button
        android:id="@+id/btn_next_or_finish"
        android:text="@string/next"
        android:textColor="@color/colorPrimaryLight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:drawableRight="@drawable/ic_next"
        style="@style/Base.Widget.AppCompat.Button.Borderless" />

</RelativeLayout>

Stacktrace:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lol.firebase/com.lol.firebase.ui.SignUpActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2660)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                       Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
                                                                          at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                          at com.lol.firebase.ui.SignUpActivity.onCreate(SignUpActivity.java:29)
                                                                          at android.app.Activity.performCreate(Activity.java:6117)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2613)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                       Caused by: java.lang.ClassNotFoundException: Didn't find class "com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager" on path: DexPathList[[zip file "/data/app/com.lol.firebase-1/base.apk", zip file "/data/app/com.lol.firebase-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.lol.firebase-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lol.firebase-1/lib/arm64, /vendor/lib64, /system/lib64]]
                                                                          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                          at android.view.LayoutInflater.createView(LayoutInflater.java:577)
                                                                          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:749)
                                                                          at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:510)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:420)
                                                                          at android.view.LayoutInflater.inflate(LayoutInflater.java:371)
                                                                          at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                          at com.lol.firebase.ui.SignUpActivity.onCreate(SignUpActivity.java:29)
                                                                          at android.app.Activity.performCreate(Activity.java:6117)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2613)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2730)
                                                                          at android.app.ActivityThread.access$800(ActivityThread.java:185)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                          at android.os.Looper.loop(Looper.java:194)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5847)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:372)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                                                        Suppressed: java.lang.ClassNotFoundException: com.lol.firebase.ui.SignUpActivity.ScrollDisabledViewPager
                                                                          at java.lang.Class.classForName(Native Method)
                                                                          at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                          at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                          at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                ... 23 more
                                                                       Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

The Stacktrace shows a ClassNotFound Exception, but I don't understand why: the class is public, and I have both constructors.


问:
Create a new variable using dplyr::mutate and pasting two existing variables for user-defined function
I would like to create a function to join the lower and higher bound of confidence intervals (named as CIlow and CIhigh) from a data frame. See the data frame below as example.

```<code>dataframe<-data.frame(CIlow_a=c(1.1,1.2),CIlow_b=c(2.1,2.2),CIlow_c=c(3.1,3.2),
                      CIhigh_a=c(1.3,1.4),CIhigh_b=c(2.3,2.4),CIhigh_c=c(3.3,3.4))
</code>```

The data frame has CIlow and CIhigh for a number of groups (named as a, b and c) and for a number of variables (in this case two, the rows of the data frame).

```<code>group<-c("a","b","c")
</code>```

To build my own function I tried the following code:

```<code>f<-function(df,gr){

enquo_df<-enquo(df)
enquo_gr<-enquo(gr)

r<-df%>%
   dplyr::mutate(UQ(paste("CI",enquo_gr,sep="_")):=
                   sprintf("(%s,%s)",
                           paste("CIlow",quo_name(enquo_gr),sep="_"),
                           paste("CIhigh",quo_name(enquo_gr),sep="_")))

return(r)
}
</code>```

However when using the function

```<code>library(dplyr)

group<-c("a","b","c")
    dataframe<-data.frame(CIlow_a=c(1.1,1.2),CIlow_b=c(2.1,2.2),CIlow_c=c(3.1,3.2),CIhigh_a=c(1.3,1.4),CIhigh_b=c(2.3,2.4),CIhigh_c=c(3.3,3.4))

f(df=dataframe,gr=group)
</code>```

I do not get the expected output

```<code>output<-data.frame(CI_a=c("(1.1,1.3)","(1.2,1.4)"),
                  CI_b=c("(2.1,2.3)","(2.2,2.4)"),
                  CI_c=c("(3.1,3.3)","(3.2,3.4)"))
</code>```

but the following error message:

Error: LHS must be a name or string

Do you know why? How could I solve this issue? Thanks in advance.

答:
Old school solution:</p>

```<code>res <- as.data.frame(matrix(NA_character_, nrow(dataframe), ncol(dataframe) / 2))
for (i in seq_along(group)) {
  var <- paste0("CI", c("low", "high"), "_", group[[i]])
  res[[i]] <- sprintf("(%s,%s)", dataframe[[var[[1]]]], dataframe[[var[[2]]]])
}
names(res) <- paste0("CI_", group)
</code>```

Body:
I would like to create a function to join the lower and higher bound of confidence intervals (named as CIlow and CIhigh) from a data frame. See the data frame below as example.

dataframe<-data.frame(CIlow_a=c(1.1,1.2),CIlow_b=c(2.1,2.2),CIlow_c=c(3.1,3.2),
                      CIhigh_a=c(1.3,1.4),CIhigh_b=c(2.3,2.4),CIhigh_c=c(3.3,3.4))

The data frame has CIlow and CIhigh for a number of groups (named as a, b and c) and for a number of variables (in this case two, the rows of the data frame).

group<-c("a","b","c")

To build my own function I tried the following code:

f<-function(df,gr){

enquo_df<-enquo(df)
enquo_gr<-enquo(gr)

r<-df%>%
   dplyr::mutate(UQ(paste("CI",enquo_gr,sep="_")):=
                   sprintf("(%s,%s)",
                           paste("CIlow",quo_name(enquo_gr),sep="_"),
                           paste("CIhigh",quo_name(enquo_gr),sep="_")))

return(r)
}

However when using the function

library(dplyr)

group<-c("a","b","c")
    dataframe<-data.frame(CIlow_a=c(1.1,1.2),CIlow_b=c(2.1,2.2),CIlow_c=c(3.1,3.2),CIhigh_a=c(1.3,1.4),CIhigh_b=c(2.3,2.4),CIhigh_c=c(3.3,3.4))

f(df=dataframe,gr=group)

I do not get the expected output

output<-data.frame(CI_a=c("(1.1,1.3)","(1.2,1.4)"),
                  CI_b=c("(2.1,2.3)","(2.2,2.4)"),
                  CI_c=c("(3.1,3.3)","(3.2,3.4)"))

but the following error message:

Error: LHS must be a name or string

Do you know why? How could I solve this issue? Thanks in advance.

Body:
Old school solution:

res <- as.data.frame(matrix(NA_character_, nrow(dataframe), ncol(dataframe) / 2))
for (i in seq_along(group)) {
  var <- paste0("CI", c("low", "high"), "_", group[[i]])
  res[[i]] <- sprintf("(%s,%s)", dataframe[[var[[1]]]], dataframe[[var[[2]]]])
}
names(res) <- paste0("CI_", group)


问:
mmapping in Python C modules - any pitfalls to be aware of?
I'm writing a Python module in C and I intend to mmap largeish blocks of memory (perhaps 500 MB). Is there anything about working in the same process space as the Python interpreter that I should be careful of?</p>

答:
No, you're fine.
On 32-bit systems, you could run out of virtual memory, or with virtual memory fragmentation not have a single chunk big enough to map as many huge files as you want. But that pitfall isn't particular to CPython.</p>


问:
Activity not opens on notification clicked
I am new to android programming please help me out what I am missing.

I receive notification but my messageActivity is not opened

```<code>NotificationManager notificationManager = (NotificationManager)
                                    getSystemService(NOTIFICATION_SERVICE);
                            NotificationCompat.Builder mbuilder = new NotificationCompat.Builder(getApplicationContext())
                                    .setContentTitle("Message from " + name)
                                    .setContentText(message)
                                    .setAutoCancel(true)
                                    .setSmallIcon(R.mipmap.ic_launcher)
                                    .setSound(soundUri);
                            if (strVibratePreference)
                                mbuilder.setVibrate(new long[]{100, 100});
                            notificationManager.notify(110, mbuilder.build());
                            Intent intent=new Intent(MessageService.this,MessageActivity.class);
                            intent.putExtra("name",name);
                            intent.putExtra("phno",_from);
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            PendingIntent pendingIntent = PendingIntent.getActivity(MessageService.this,0,intent,0);
                            mbuilder.setContentIntent(pendingIntent);
</code>```

答:
add this end code</p>

```<code>Notification n = mbuilder.build();
notificationManager.notify(YOUR_NOTIF_ID, n);
</code>```

Body:
I am new to android programming please help me out what I am missing.

I receive notification but my messageActivity is not opened

NotificationManager notificationManager = (NotificationManager)
                                    getSystemService(NOTIFICATION_SERVICE);
                            NotificationCompat.Builder mbuilder = new NotificationCompat.Builder(getApplicationContext())
                                    .setContentTitle("Message from " + name)
                                    .setContentText(message)
                                    .setAutoCancel(true)
                                    .setSmallIcon(R.mipmap.ic_launcher)
                                    .setSound(soundUri);
                            if (strVibratePreference)
                                mbuilder.setVibrate(new long[]{100, 100});
                            notificationManager.notify(110, mbuilder.build());
                            Intent intent=new Intent(MessageService.this,MessageActivity.class);
                            intent.putExtra("name",name);
                            intent.putExtra("phno",_from);
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            PendingIntent pendingIntent = PendingIntent.getActivity(MessageService.this,0,intent,0);
                            mbuilder.setContentIntent(pendingIntent);

Body:
add this end code

Notification n = mbuilder.build();
notificationManager.notify(YOUR_NOTIF_ID, n);


问:
How to get value of Html.DropDownList in the controller?
I have assigned the following viewbag in the controller

```<code>public ActionResult new_vehicle()
    {
        ViewBag.customers = new SelectList(db.customers, "cust_id", "cust_name");
        return View(db.vehicles.ToList());
    }
</code>```

and the code in view is

```<code> @Html.DropDownList("customers", "Select Customer");
</code>```

the code for add function is

```<code>public ActionResult veh_AddEdit()
    {
        int id = Convert.ToInt32(Request["vehiddenID"]);
        if (id == 0)
        {

            vehicle veh = new vehicle();
            Session["veh_id"] = "";

            veh.cust_id_fk = Convert.ToInt32(Request.Form["customers"]);
            veh.veh_make = Request["vemake"];
            veh.veh_name = Request["vename"];
            veh.veh_model = Request["vemodel"];
            db.vehicles.Add(veh);
            db.SaveChanges();
            int latestEmpId = veh.veh_id;
        }

        return RedirectToAction("new_vehicle");
    }
</code>```

The problem is that its not getting the selected value i.e foreign key in the controller.

答:
In your controller you can pass in viewbag IEnumerable<SelectListItem>

```<code>public ActionResult new_vehicle()
{
    ViewBag.customers = db.customers.Select(i=>new SelectListItem() { Text = i.cust_name, Value=i.cust_id });
    return View(db.vehicles.ToList());
}
</code>```

Then in your view you can render dropdown like that

```<code>@Html.DropDownList("customers", (IEnumerable<SelectListItem>)ViewBag.customers, "Select Customer")
</code>```

And then in your controller in your method veh_AddEdit you can access it like Request["customers"]

Body:
I have assigned the following viewbag in the controller

public ActionResult new_vehicle()
    {
        ViewBag.customers = new SelectList(db.customers, "cust_id", "cust_name");
        return View(db.vehicles.ToList());
    }

and the code in view is

 @Html.DropDownList("customers", "Select Customer");

the code for add function is

public ActionResult veh_AddEdit()
    {
        int id = Convert.ToInt32(Request["vehiddenID"]);
        if (id == 0)
        {

            vehicle veh = new vehicle();
            Session["veh_id"] = "";

            veh.cust_id_fk = Convert.ToInt32(Request.Form["customers"]);
            veh.veh_make = Request["vemake"];
            veh.veh_name = Request["vename"];
            veh.veh_model = Request["vemodel"];
            db.vehicles.Add(veh);
            db.SaveChanges();
            int latestEmpId = veh.veh_id;
        }

        return RedirectToAction("new_vehicle");
    }

The problem is that its not getting the selected value i.e foreign key in the controller.

Body:
In your controller you can pass in viewbag IEnumerable<SelectListItem>

public ActionResult new_vehicle()
{
    ViewBag.customers = db.customers.Select(i=>new SelectListItem() { Text = i.cust_name, Value=i.cust_id });
    return View(db.vehicles.ToList());
}

Then in your view you can render dropdown like that

@Html.DropDownList("customers", (IEnumerable<SelectListItem>)ViewBag.customers, "Select Customer")

And then in your controller in your method veh_AddEdit you can access it like Request["customers"]


问:
Recyclerview displaying only the last json data?
I am trying to display data in a recycler view in android. i but it keeps displaying only the last datas and i dont know why.i seem to be doing everything right. And the recycler view has a view pager.

this is my
Myadapter class

```<code>public class MyAdapter extends RecyclerView.Adapter<MyHolder> {
    Context c;
    List<Getter> getter;

    public MyAdapter(List<Getter> getter, Context c) {
        super();
        this.c = c;
        this.getter = getter;
    }

    //INITIALIZE VIEWHODER
    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //VIEW OBJ
        View v= LayoutInflater.from(parent.getContext()).inflate(R.layout.model,null);

        //HOLDER
        MyHolder holder=new MyHolder(v);

        return holder;
    }

    //BIND VIEW TO DATA
    @Override
    public void onBindViewHolder(MyHolder holder, int position) {

        String images[] = {getter.get(position).getUrl1(), getter.get(position).getUrl2()};
        holder.gamename.setText(getter.get(position).getGame_name());
        holder.cost.setText(getter.get(position).getCost());
        holder.usname.setText(getter.get(position).getFull_name());
        Picasso.with(c)
                .load(getter.get(position).getPicture())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.error)
                .transform(new CircleTransform())
                .fit()
                .into(holder.usimage);

        CustomPagerAdapter mCustomPagerAdapter = new CustomPagerAdapter(c,images);
        holder.mViewPager.setAdapter(mCustomPagerAdapter);

        holder.indicator.setViewPager(holder.mViewPager);

        holder.setItemClickListener(new ItemClickListener() {
            @Override
            public void onItemClick(View v, int pos) {
                Snackbar.make(v,getter.get(pos).getGame_name(),Snackbar.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    public int getItemCount() {
        return getter.size();
    }
}
</code>```

This is my mainactivty class

```<code> public class All_timeline extends Fragment {
        SqlHandler sqlHandler;
        RecyclerView rv;
        MyAdapter adapter;
        private List<Getter> getter;

        public All_timeline() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View x = inflater.inflate(R.layout.all_timeline, container, false);
            sqlHandler = new SqlHandler(getActivity());
            //recycler
            rv = (RecyclerView) x.findViewById(R.id.mRecycler);
            getter= new ArrayList<>();
            rv.setLayoutManager(new LinearLayoutManager(getActivity()));

            rv.setItemAnimator(new DefaultItemAnimator());
           rv.addItemDecoration(new SimpleDividerItemDecoration(getResources()));

            registerUser("arinzeaco@gmail.com");

            adapter=new MyAdapter(getter,getActivity());
            rv.setAdapter(adapter);
            return x;
        }

        public void registerUser(final String email) {

            OkHttpClient client = new OkHttpClient();
            RequestBody body = new FormBody.Builder()
                    .add("username", email)
                    .build();
            Request request = new Request.Builder().url("http://www.thethinker.com.ng/gamer/allpost.php").post(body).build();
            Call call = client.newCall(request);
            call.enqueue(new Callback() {

                @Override
                public void onFailure(Call call, IOException e) {
                    Toast.makeText(getActivity(), "Registration failed",
                            Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(Call call, Response response) throws IOException {
                    final String myResponse = response.body().string();
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            JSONObject jso;
                            Getter contactListItems = new Getter();
                            try {
                                jso = new JSONObject(myResponse);
                                JSONArray categories = jso.getJSONArray("posts");

                                for (int i = 0; i < categories.length(); i++) {
                                    String image1 = categories.getJSONObject(i).getString("image_1");
                                    String image2 = categories.getJSONObject(i).getString("image_2");
                                    String username = categories.getJSONObject(i).getString("username");
                                    String video_url = categories.getJSONObject(i).getString("video_url");
                                    String liked = categories.getJSONObject(i).getString("liked");
                                    String cost = categories.getJSONObject(i).getString("cost");
                                    String following = categories.getJSONObject(i).getString("following");
                                    String game_name = categories.getJSONObject(i).getString("game_name");
                                    String full_name = categories.getJSONObject(i).getString("full_name");
                                    String userimage = categories.getJSONObject(i).getString("userimage");

                                    contactListItems.setUsername(username);
                                    contactListItems.setGame_name(game_name);
                                    contactListItems.setCost(cost);
                                    contactListItems.setFollowing(following);
                                    contactListItems.setLiked(liked);
                                    contactListItems.setFull_name(full_name);
                                    contactListItems.setVideo(video_url);
                                    contactListItems.setUrl1(image1);
                                    contactListItems.setUrl2(image2);
                                    contactListItems.setPicture(userimage);

                                    getter.add(contactListItems);

                                }

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }});

                        }
                    });

        }
    }
</code>```

I have also check other stackoverflow questions like RecyclerView displaying the last item in the adapter several times. Need all adapter items to show in RecyclerView. but i just don't get what i am doing wrong.

答:
I think it related to concurrency issue, please try to call http method after you set adapter, and don't forget to call notifyDataSetChanged() after all data inserted. One more think, make sure you insert different Getter instance for every item

for example in onCreateView

     adapter=new MyAdapter(getter,getActivity());
     rv.setAdapter(adapter);
     registerUser("arinzeaco@gmail.com");

in onResponse:

```<code> @Override
 public void onResponse(Call call, Response response) throws IOException {
 final String myResponse = response.body().string();
 getActivity().runOnUiThread(new Runnable() {
    @Override
    public void run() {
        JSONObject jso;
        try {
            jso = new JSONObject(myResponse);
            JSONArray categories = jso.getJSONArray("posts");

            for (int i = 0; i < categories.length(); i++) {
                Getter contactListItems = new Getter();
                String image1 = categories.getJSONObject(i).getString("image_1");
                String image2 = categories.getJSONObject(i).getString("image_2");
                String username = categories.getJSONObject(i).getString("username");
                String video_url = categories.getJSONObject(i).getString("video_url");
                String liked = categories.getJSONObject(i).getString("liked");
                String cost = categories.getJSONObject(i).getString("cost");
                String following = categories.getJSONObject(i).getString("following");
                String game_name = categories.getJSONObject(i).getString("game_name");
                String full_name = categories.getJSONObject(i).getString("full_name");
                String userimage = categories.getJSONObject(i).getString("userimage");

                contactListItems.setUsername(username);
                contactListItems.setGame_name(game_name);
                contactListItems.setCost(cost);
                contactListItems.setFollowing(following);
                contactListItems.setLiked(liked);
                contactListItems.setFull_name(full_name);
                contactListItems.setVideo(video_url);
                contactListItems.setUrl1(image1);
                contactListItems.setUrl2(image2);
                contactListItems.setPicture(userimage);

                getter.add(contactListItems);
            }
            adapter.notifyDataSetChanged();

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }});

    }
});
</code>```

Body:
I am trying to display data in a recycler view in android. i but it keeps displaying only the last datas and i dont know why.i seem to be doing everything right. And the recycler view has a view pager.

this is my
Myadapter class

public class MyAdapter extends RecyclerView.Adapter<MyHolder> {
    Context c;
    List<Getter> getter;

    public MyAdapter(List<Getter> getter, Context c) {
        super();
        this.c = c;
        this.getter = getter;
    }

    //INITIALIZE VIEWHODER
    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //VIEW OBJ
        View v= LayoutInflater.from(parent.getContext()).inflate(R.layout.model,null);

        //HOLDER
        MyHolder holder=new MyHolder(v);

        return holder;
    }

    //BIND VIEW TO DATA
    @Override
    public void onBindViewHolder(MyHolder holder, int position) {

        String images[] = {getter.get(position).getUrl1(), getter.get(position).getUrl2()};
        holder.gamename.setText(getter.get(position).getGame_name());
        holder.cost.setText(getter.get(position).getCost());
        holder.usname.setText(getter.get(position).getFull_name());
        Picasso.with(c)
                .load(getter.get(position).getPicture())
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.error)
                .transform(new CircleTransform())
                .fit()
                .into(holder.usimage);

        CustomPagerAdapter mCustomPagerAdapter = new CustomPagerAdapter(c,images);
        holder.mViewPager.setAdapter(mCustomPagerAdapter);

        holder.indicator.setViewPager(holder.mViewPager);

        holder.setItemClickListener(new ItemClickListener() {
            @Override
            public void onItemClick(View v, int pos) {
                Snackbar.make(v,getter.get(pos).getGame_name(),Snackbar.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    public int getItemCount() {
        return getter.size();
    }
}

This is my mainactivty class

 public class All_timeline extends Fragment {
        SqlHandler sqlHandler;
        RecyclerView rv;
        MyAdapter adapter;
        private List<Getter> getter;

        public All_timeline() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View x = inflater.inflate(R.layout.all_timeline, container, false);
            sqlHandler = new SqlHandler(getActivity());
            //recycler
            rv = (RecyclerView) x.findViewById(R.id.mRecycler);
            getter= new ArrayList<>();
            rv.setLayoutManager(new LinearLayoutManager(getActivity()));

            rv.setItemAnimator(new DefaultItemAnimator());
           rv.addItemDecoration(new SimpleDividerItemDecoration(getResources()));

            registerUser("arinzeaco@gmail.com");

            adapter=new MyAdapter(getter,getActivity());
            rv.setAdapter(adapter);
            return x;
        }

        public void registerUser(final String email) {

            OkHttpClient client = new OkHttpClient();
            RequestBody body = new FormBody.Builder()
                    .add("username", email)
                    .build();
            Request request = new Request.Builder().url("http://www.thethinker.com.ng/gamer/allpost.php").post(body).build();
            Call call = client.newCall(request);
            call.enqueue(new Callback() {

                @Override
                public void onFailure(Call call, IOException e) {
                    Toast.makeText(getActivity(), "Registration failed",
                            Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onResponse(Call call, Response response) throws IOException {
                    final String myResponse = response.body().string();
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            JSONObject jso;
                            Getter contactListItems = new Getter();
                            try {
                                jso = new JSONObject(myResponse);
                                JSONArray categories = jso.getJSONArray("posts");

                                for (int i = 0; i < categories.length(); i++) {
                                    String image1 = categories.getJSONObject(i).getString("image_1");
                                    String image2 = categories.getJSONObject(i).getString("image_2");
                                    String username = categories.getJSONObject(i).getString("username");
                                    String video_url = categories.getJSONObject(i).getString("video_url");
                                    String liked = categories.getJSONObject(i).getString("liked");
                                    String cost = categories.getJSONObject(i).getString("cost");
                                    String following = categories.getJSONObject(i).getString("following");
                                    String game_name = categories.getJSONObject(i).getString("game_name");
                                    String full_name = categories.getJSONObject(i).getString("full_name");
                                    String userimage = categories.getJSONObject(i).getString("userimage");

                                    contactListItems.setUsername(username);
                                    contactListItems.setGame_name(game_name);
                                    contactListItems.setCost(cost);
                                    contactListItems.setFollowing(following);
                                    contactListItems.setLiked(liked);
                                    contactListItems.setFull_name(full_name);
                                    contactListItems.setVideo(video_url);
                                    contactListItems.setUrl1(image1);
                                    contactListItems.setUrl2(image2);
                                    contactListItems.setPicture(userimage);

                                    getter.add(contactListItems);

                                }

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }});

                        }
                    });

        }
    }

I have also check other stackoverflow questions like RecyclerView displaying the last item in the adapter several times. Need all adapter items to show in RecyclerView. but i just don't get what i am doing wrong.

Body:
I think it related to concurrency issue, please try to call http method after you set adapter, and don't forget to call notifyDataSetChanged() after all data inserted. One more think, make sure you insert different Getter instance for every item

for example in onCreateView

     adapter=new MyAdapter(getter,getActivity());
     rv.setAdapter(adapter);
     registerUser("arinzeaco@gmail.com");

in onResponse:

 @Override
 public void onResponse(Call call, Response response) throws IOException {
 final String myResponse = response.body().string();
 getActivity().runOnUiThread(new Runnable() {
    @Override
    public void run() {
        JSONObject jso;
        try {
            jso = new JSONObject(myResponse);
            JSONArray categories = jso.getJSONArray("posts");

            for (int i = 0; i < categories.length(); i++) {
                Getter contactListItems = new Getter();
                String image1 = categories.getJSONObject(i).getString("image_1");
                String image2 = categories.getJSONObject(i).getString("image_2");
                String username = categories.getJSONObject(i).getString("username");
                String video_url = categories.getJSONObject(i).getString("video_url");
                String liked = categories.getJSONObject(i).getString("liked");
                String cost = categories.getJSONObject(i).getString("cost");
                String following = categories.getJSONObject(i).getString("following");
                String game_name = categories.getJSONObject(i).getString("game_name");
                String full_name = categories.getJSONObject(i).getString("full_name");
                String userimage = categories.getJSONObject(i).getString("userimage");

                contactListItems.setUsername(username);
                contactListItems.setGame_name(game_name);
                contactListItems.setCost(cost);
                contactListItems.setFollowing(following);
                contactListItems.setLiked(liked);
                contactListItems.setFull_name(full_name);
                contactListItems.setVideo(video_url);
                contactListItems.setUrl1(image1);
                contactListItems.setUrl2(image2);
                contactListItems.setPicture(userimage);

                getter.add(contactListItems);
            }
            adapter.notifyDataSetChanged();

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }});

    }
});


问:
Oracle TOAD and Materialised View
i am new to oracle.Already there is a store procedure which fetches data from many tables.Due to performance issue,i need to modify it.So i want to know about materialised view (since,i already searched it in net,but i am not able to understand it).can anyone explain the features of it?

Also,i am using TOAD for oracle.Can someone suggest me any materials(book,websites etc.) to learn?

答: I'll take the Toad portion - you can get a ton of great help online for free at ToadWorld.com.  I have a 35 page free tutorial there as well link text</p>

Title: Oracle TOAD and Materialised View


问:
How can I use Number() to convert a string to number without losing the decimal points?
I tried

```<code>num = 0.5;
num =  Number(num.toPrecision(2));
</code>```

I want the result to be 0.50, but it's returning 0.5.

答:
The .toPrecision() method returns a string representation of a number. If you pass that to Number(), it parses it as a number and you get a number value as a result. The number 0.5 and the number 0.50 are precisely equal; when you print or log the number 0.5 you don't get any extra digits because that's just how the default string conversion of numbers works. That, in fact, is the reason .toPrecision() exists.

The nature of JavaScript numbers is such that it just doesn't make sense to want to retain trailing fractional zero digits. Numbers are binary floating point values internally, so trailing decimal fractional digits have no place.

Body:
I tried

num = 0.5;
num =  Number(num.toPrecision(2));

I want the result to be 0.50, but it's returning 0.5.