问:
Using TextWatcher to calculate average between EditTexts
I have a problem with a project on android studio and i need your help. I have created a line with 3 EditText and one Textview. I want to write numbers on the EditText and calculate the average on the Textview. I also use a button to create a new line when i click it. I achieved the calculation on the first line but every time i try to calculate a line where the button created, i get no result. Here is my code:

```<code>public class MainActivity extends AppCompatActivity {
private LinearLayout parentLinearLayout;
private BreakIterator resultsText;
EditText editText1;
EditText editText2;
EditText editText3;
TextView textViewResult;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    parentLinearLayout = (LinearLayout) findViewById(R.id.parent_linear_layout);
    editText1 = (EditText) findViewById(R.id.number_edit_text1);
    editText2 = (EditText) findViewById(R.id.number_edit_text2);
    editText3 = (EditText) findViewById(R.id.number_edit_text3);

    textViewResult = (TextView) findViewById(R.id.number_text_view);

    editText1.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub
        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());
        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    editText2.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    editText3.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
}

private String avg() {
    int number1;
    int number2;
    int number3;
    if(editText1.getText().toString() != "" && editText1.getText().length() > 0) {
        number1 = Integer.parseInt(editText1.getText().toString());
    } else {
        number1 = 0;
    }
    if(editText2.getText().toString() != "" && editText2.getText().length() > 0) {
        number2 = Integer.parseInt(editText2.getText().toString());
    } else {
        number2 = 0;
    }
    if(editText3.getText().toString() != "" && editText3.getText().length() > 0) {
        number3 = Integer.parseInt(editText3.getText().toString());
    } else {
        number3 = 0;
    }

    return Integer.toString((number1 + number2 + number3)/3 );
}

public void onAddField(View v) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View rowView = inflater.inflate(R.layout.field, null);
    // Add the new row before the add field button.
    parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

}

public void onDelete(View v) {
    parentLinearLayout.removeView((View) v.getParent());
}

}
</code>```

And two .xml files:
activity_main.xml

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_linear_layout"
    android:layout_width="match_parent"
    android:layout_height="495dp"
    android:layout_margin="0dp"
    android:orientation="vertical"
    android:weightSum="1">

    <TableLayout
        android:id="@+id/tlTable01"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#CCC"
        android:orientation="vertical"
        android:paddingTop="0dp"
        android:theme="@style/AppTheme">

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#7CFC00"
            android:gravity="center_horizontal"
            android:paddingBottom="1dp">

            <TextView
                android:id="@+id/textView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#7CFC00"
                android:gravity="left"
                android:padding="5dp"
                android:text="Scoring List"
                android:textSize="18dp"
                android:textStyle="bold"
                android:typeface="serif" />

            <EditText
                android:layout_width="190dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="1dp"
                android:background="#FFF"
                android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
                android:gravity="center_horizontal"
                android:inputType="text"
                android:padding="5dp"
                android:text="Examiner's Name"
                android:textSize="18dp"
                android:textStyle="bold"
                android:typeface="serif" />
        </TableRow>
    </TableLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_weight="0.01"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="Student's Name"
        android:textStyle="bold"
        android:typeface="serif" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="User Interface"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="Functions"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="User Manual"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="AVG"
        android:textStyle="bold"
        android:typeface="serif"/>

    <TextView
        android:layout_height="match_parent"
        android:layout_weight="2.35"
        android:gravity="left"
        android:layout_marginLeft="5dp"
        android:layout_width="wrap_content" />
    </LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_weight="0.01"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/word_edit_text"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
        android:gravity="center_horizontal"
        android:inputType="text" />

    <EditText
        android:id="@+id/number_edit_text1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <EditText
        android:id="@+id/number_edit_text2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <EditText
        android:id="@+id/number_edit_text3"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <TextView
        android:id="@+id/number_text_view"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:textSize="18dp"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginTop="9dp"/>

    <Button
        android:id="@+id/delete_button"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_weight="2.15"
        android:background="@android:drawable/ic_delete"
        android:onClick="onDelete" />
</LinearLayout>

<Button
        android:id="@+id/add_field_button"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="#555"
        android:onClick="onAddField"
        android:paddingLeft="5dp"
        android:text="Add Field"
        android:textColor="#FFF" />
</LinearLayout>
</code>```

and field.xml

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_weight="0.01">

<EditText
    android:id="@+id/number_edit_text"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text1"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text2"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text3"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<TextView
    android:id="@+id/number_text_view"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:gravity="center_horizontal"
    android:textSize="18dp"
    android:textStyle="bold"
    android:typeface="serif"
    android:layout_marginTop="9dp"/>

<Button
    android:id="@+id/delete_button"
    android:layout_width="0dp"
    android:layout_height="40dp"
    android:layout_weight="2.15"
    android:background="@android:drawable/ic_delete"
    android:onClick="onDelete" />

</LinearLayout>
</code>```

Thank you in advance!

答:
Here is working code for you:

```<code>public void onAddField(View v) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View rowView = inflater.inflate(R.layout.field, null);
    ((EditText) rowView.findViewById(R.id.number_edit_text1)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub
        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));            }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    ((EditText) rowView.findViewById(R.id.number_edit_text2)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));
        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    ((EditText) rowView.findViewById(R.id.number_edit_text3)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    // Add the new row before the add field button.
    parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

}

private String avg(EditText viewById, EditText viewById1, EditText viewById2) {
    int number1;
    int number2;
    int number3;
    if (viewById.getText().toString() != "" && viewById.getText().length() > 0) {
        number1 = Integer.parseInt(viewById.getText().toString());
    } else {
        number1 = 0;
    }
    if (viewById1.getText().toString() != "" && viewById1.getText().length() > 0) {
        number2 = Integer.parseInt(viewById1.getText().toString());
    } else {
        number2 = 0;
    }
    if (viewById2.getText().toString() != "" && viewById2.getText().length() > 0) {
        number3 = Integer.parseInt(viewById2.getText().toString());
    } else {
        number3 = 0;
    }

    return Integer.toString((number1 + number2 + number3) / 3);
}
</code>```

It didn't worked because you didn't assigned any listeners to the fields.

Also, i would suggest you to use RecyclerView for the views that you are adding.

Note

avg function is new function, don't replace it with yours.

Hope it helps :)

Body:
I have a problem with a project on android studio and i need your help. I have created a line with 3 EditText and one Textview. I want to write numbers on the EditText and calculate the average on the Textview. I also use a button to create a new line when i click it. I achieved the calculation on the first line but every time i try to calculate a line where the button created, i get no result. Here is my code:

public class MainActivity extends AppCompatActivity {
private LinearLayout parentLinearLayout;
private BreakIterator resultsText;
EditText editText1;
EditText editText2;
EditText editText3;
TextView textViewResult;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    parentLinearLayout = (LinearLayout) findViewById(R.id.parent_linear_layout);
    editText1 = (EditText) findViewById(R.id.number_edit_text1);
    editText2 = (EditText) findViewById(R.id.number_edit_text2);
    editText3 = (EditText) findViewById(R.id.number_edit_text3);

    textViewResult = (TextView) findViewById(R.id.number_text_view);

    editText1.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub
        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());
        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    editText2.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    editText3.addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            textViewResult.setText(avg());

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
}

private String avg() {
    int number1;
    int number2;
    int number3;
    if(editText1.getText().toString() != "" && editText1.getText().length() > 0) {
        number1 = Integer.parseInt(editText1.getText().toString());
    } else {
        number1 = 0;
    }
    if(editText2.getText().toString() != "" && editText2.getText().length() > 0) {
        number2 = Integer.parseInt(editText2.getText().toString());
    } else {
        number2 = 0;
    }
    if(editText3.getText().toString() != "" && editText3.getText().length() > 0) {
        number3 = Integer.parseInt(editText3.getText().toString());
    } else {
        number3 = 0;
    }

    return Integer.toString((number1 + number2 + number3)/3 );
}

public void onAddField(View v) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View rowView = inflater.inflate(R.layout.field, null);
    // Add the new row before the add field button.
    parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

}

public void onDelete(View v) {
    parentLinearLayout.removeView((View) v.getParent());
}

}

And two .xml files:
activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_linear_layout"
    android:layout_width="match_parent"
    android:layout_height="495dp"
    android:layout_margin="0dp"
    android:orientation="vertical"
    android:weightSum="1">

    <TableLayout
        android:id="@+id/tlTable01"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#CCC"
        android:orientation="vertical"
        android:paddingTop="0dp"
        android:theme="@style/AppTheme">

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#7CFC00"
            android:gravity="center_horizontal"
            android:paddingBottom="1dp">

            <TextView
                android:id="@+id/textView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#7CFC00"
                android:gravity="left"
                android:padding="5dp"
                android:text="Scoring List"
                android:textSize="18dp"
                android:textStyle="bold"
                android:typeface="serif" />

            <EditText
                android:layout_width="190dp"
                android:layout_height="match_parent"
                android:layout_marginLeft="1dp"
                android:background="#FFF"
                android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
                android:gravity="center_horizontal"
                android:inputType="text"
                android:padding="5dp"
                android:text="Examiner's Name"
                android:textSize="18dp"
                android:textStyle="bold"
                android:typeface="serif" />
        </TableRow>
    </TableLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_weight="0.01"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="Student's Name"
        android:textStyle="bold"
        android:typeface="serif" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="User Interface"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="Functions"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="User Manual"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginLeft="5dp"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:text="AVG"
        android:textStyle="bold"
        android:typeface="serif"/>

    <TextView
        android:layout_height="match_parent"
        android:layout_weight="2.35"
        android:gravity="left"
        android:layout_marginLeft="5dp"
        android:layout_width="wrap_content" />
    </LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_weight="0.01"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/word_edit_text"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZαβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
        android:gravity="center_horizontal"
        android:inputType="text" />

    <EditText
        android:id="@+id/number_edit_text1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <EditText
        android:id="@+id/number_edit_text2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <EditText
        android:id="@+id/number_edit_text3"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:inputType="number" />

    <TextView
        android:id="@+id/number_text_view"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="5"
        android:gravity="center_horizontal"
        android:textSize="18dp"
        android:textStyle="bold"
        android:typeface="serif"
        android:layout_marginTop="9dp"/>

    <Button
        android:id="@+id/delete_button"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_weight="2.15"
        android:background="@android:drawable/ic_delete"
        android:onClick="onDelete" />
</LinearLayout>

<Button
        android:id="@+id/add_field_button"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="#555"
        android:onClick="onAddField"
        android:paddingLeft="5dp"
        android:text="Add Field"
        android:textColor="#FFF" />
</LinearLayout>

and field.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_weight="0.01">

<EditText
    android:id="@+id/number_edit_text"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text1"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text2"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<EditText
    android:id="@+id/number_edit_text3"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:inputType="textCapWords"
    android:gravity="center_horizontal" />
<TextView
    android:id="@+id/number_text_view"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="5"
    android:gravity="center_horizontal"
    android:textSize="18dp"
    android:textStyle="bold"
    android:typeface="serif"
    android:layout_marginTop="9dp"/>

<Button
    android:id="@+id/delete_button"
    android:layout_width="0dp"
    android:layout_height="40dp"
    android:layout_weight="2.15"
    android:background="@android:drawable/ic_delete"
    android:onClick="onDelete" />

</LinearLayout>

Thank you in advance!

Body:
Here is working code for you:

public void onAddField(View v) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View rowView = inflater.inflate(R.layout.field, null);
    ((EditText) rowView.findViewById(R.id.number_edit_text1)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub
        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));            }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    ((EditText) rowView.findViewById(R.id.number_edit_text2)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));
        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    ((EditText) rowView.findViewById(R.id.number_edit_text3)).addTextChangedListener(new TextWatcher() {

        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            // TODO Auto-generated method stub

        }

        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            ((TextView) rowView.findViewById(R.id.number_text_view)).setText(
                    avg(((EditText) rowView.findViewById(R.id.number_edit_text1)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text2)),
                            ((EditText) rowView.findViewById(R.id.number_edit_text3))));

        }

        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
    // Add the new row before the add field button.
    parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

}

private String avg(EditText viewById, EditText viewById1, EditText viewById2) {
    int number1;
    int number2;
    int number3;
    if (viewById.getText().toString() != "" && viewById.getText().length() > 0) {
        number1 = Integer.parseInt(viewById.getText().toString());
    } else {
        number1 = 0;
    }
    if (viewById1.getText().toString() != "" && viewById1.getText().length() > 0) {
        number2 = Integer.parseInt(viewById1.getText().toString());
    } else {
        number2 = 0;
    }
    if (viewById2.getText().toString() != "" && viewById2.getText().length() > 0) {
        number3 = Integer.parseInt(viewById2.getText().toString());
    } else {
        number3 = 0;
    }

    return Integer.toString((number1 + number2 + number3) / 3);
}

It didn't worked because you didn't assigned any listeners to the fields.

Also, i would suggest you to use RecyclerView for the views that you are adding.

Note

avg function is new function, don't replace it with yours.

Hope it helps :)


来源: stackexchange

问:
Git - Forking without Github
Is the function of "forking" specific to github? or is there a purely git process for creating "copied" child repositories that can pull updates from the parent? If so, how?

EDIT : I must be confused about what git clone does then.  It was my understanding that git clone is what I do on my machine to get a local copy of the repository to make changes to, commit, and push from.  We are currently hosting our repos with gitosis.  So if I wanted to accompish a 'fork' I would clone the repository on the gitosis server itself (at the origin)?  Would that create a new git address?

答:
Any time you git clone a repository, you've effectively created a fork. The only thing GitHub's fork functionality does is make the clone a GitHub repo, with a Web page and graphs and stats and all that good stuff.

Also, when you clone a repository, Git automatically makes the original repository the default “upstream” repo (the remote called origin). So, out of the box, git pull without arguments should pull straight from the original.

ContentLicense: CC BY-SA 2.5

Title: Git - Forking without Github


问:
Javascript can't get element's value, value equals undefined
I would like some help please.

I've recently started learning javascript, and I came across an error I can't fix, it seems simple, yet I can't find a way to fix it.
So, I have a table:

And the point of the table is to give the squares with the value "X" when clicked, a red background (changing css class), and all others green, but to do that, I need to get the value of the square, and it is always returning "undefined".

The HTML table looks like this:

```<code><table>
    <tr>
        <td class="normal" id="11" value="0" onclick="alterar('11');">0</td>
        <td class="normal" id="12" value="1" onclick="alterar('12');">1</td>
        <td class="normal" id="13" value="2" onclick="alterar('13');">2</td>
        <td class="normal" id="14" value="X" onclick="alterar('14');">X</td>
        <td class="normal" id="15" value="1" onclick="alterar('15');">1</td>
        <td class="normal" id="16" value="0" onclick="alterar('16');">0</td>
        <td class="normal" id="17" value="0" onclick="alterar('17');">0</td>
    </tr>
        <td class="normal" id="21" value="0" onclick="alterar('21');">0</td>
        <td class="normal" id="22" value="1" onclick="alterar('22');">1</td>
        <td class="normal" id="23" value="2" onclick="alterar('23');">2</td>
        <td class="normal" id="24" value="X" onclick="alterar('24');">X</td>
        <td class="normal" id="25" value="1" onclick="alterar('25');">1</td>
        <td class="normal" id="26" value="0" onclick="alterar('26');">0</td>
        <td class="normal" id="27" value="0" onclick="alterar('27');">0</td>
    </tr>
        <td class="normal" id="31" value="0" onclick="alterar('31');">0</td>
        <td class="normal" id="32" value="1" onclick="alterar('32');">1</td>
        <td class="normal" id="33" value="2" onclick="alterar('33');">2</td>
        <td class="normal" id="34" value="X" onclick="alterar('34');">X</td>
        <td class="normal" id="35" value="1" onclick="alterar('35');">1</td>
        <td class="normal" id="36" value="0" onclick="alterar('36');">0</td>
        <td class="normal" id="37" value="0" onclick="alterar('37');">0</td>
    </tr>
        <td class="normal" id="41" value="0" onclick="alterar('41');">0</td>
        <td class="normal" id="42" value="1" onclick="alterar('42');">1</td>
        <td class="normal" id="43" value="2" onclick="alterar('43');">2</td>
        <td class="normal" id="44" value="X" onclick="alterar('44');">X</td>
        <td class="normal" id="45" value="1" onclick="alterar('45');">1</td>
        <td class="normal" id="46" value="0" onclick="alterar('46');">0</td>
        <td class="normal" id="47" value="0" onclick="alterar('47');">0</td>
    </tr>
</table>
</code>```

My javascript code looks like this:

```<code>function alterar(obj){

  var id = document.getElementById(obj).id;
  var value = document.getElementById(id).value;

  if (value == 'X'){
    obj.className='red';
  } else {
    obj.className='green';
    }
}

</script>
</code>```

And if for example, I'd use the square "44", which value is "X", it tells me that

```<code>    <td class="normal" id="44" value="X" onclick="alterar('44');">X</td>
</code>```

I'd like to thank everyone in advance for their times.

答:
For my understanding you try to read the value of the  tag attribute.
If you want to get the  tag attribute using java script use it as below mentioned:

```<code>// Get all images in the document
var images = document.body.getElementsByTagName("img");
// Get the src attribute of the first one
var src0 = images[0].getAttribute("src");
// Get the src attribute of the second simply by reading the property
var src1 = images[1].src;
</code>```

For Your case get the Value:

```<code>var id = document.getElementById(obj).id;
var value = id.getAttribute("value");
</code>```

and also you can add class by checking condition like:

```<code>id.className += " otherclass";
</code>```

I hope this will helpfull for you.

ContentLicense: CC BY-SA 4.0

Body:
I would like some help please.

I've recently started learning javascript, and I came across an error I can't fix, it seems simple, yet I can't find a way to fix it.
So, I have a table:

And the point of the table is to give the squares with the value "X" when clicked, a red background (changing css class), and all others green, but to do that, I need to get the value of the square, and it is always returning "undefined".

The HTML table looks like this:

        0
        1
        2
        X
        1
        0
        0

        0
        1
        2
        X
        1
        0
        0

        0
        1
        2
        X
        1
        0
        0

        0
        1
        2
        X
        1
        0
        0

My javascript code looks like this:

function alterar(obj){

  var id = document.getElementById(obj).id;
  var value = document.getElementById(id).value;

  if (value == 'X'){
    obj.className='red';
  } else {
    obj.className='green';
    }
}

</script>

And if for example, I'd use the square "44", which value is "X", it tells me that

    X

I'd like to thank everyone in advance for their times.

Body:
For my understanding you try to read the value of the <td> tag attribute.
If you want to get the <html> tag attribute using java script use it as below mentioned:

// Get all images in the document
var images = document.body.getElementsByTagName("img");
// Get the src attribute of the first one
var src0 = images[0].getAttribute("src");
// Get the src attribute of the second simply by reading the property
var src1 = images[1].src;

For Your case get the Value:

var id = document.getElementById(obj).id;
var value = id.getAttribute("value");

and also you can add class by checking condition like:

id.className += " otherclass";

I hope this will helpfull for you.

ContentLicense: CC BY-SA 3.0


问:
Converting Json data to html?
```<code><script>
  $(document).ready(function() {

    $("#getMessage").on("click", function() {
      $.getJSON("/json/cats.json", function(json) {

        var html = "";
        // Only change code below this line.
        json.forEach(function(val){
                     var keys = Object.keys(val);
                     html+="<div class='cat'>";
                     keys.forEach(function(key){
                       html+="<strong>"+key+"</strong>;"+val[key]+"<br>";
                     });
        html+="</div><br>";
                     });

        // Only change code above this line.

        $(".message").html(html);

      });
    });
  });
</script>

<div class="container-fluid">
  <div class = "row text-center">
    <h2>Cat Photo Finder</h2>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12 well message">
      The message will go here
   </div>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12">
      <button id = "getMessage" class = "btn btn-primary">
        Get Message
      </button>
    </div>
  </div>
</div>
</code>```

<p>So I am an amateur front end developer I just finished some basic JS and started learning about json and jquery but this above bit of code is going over my head.
Could some one please explain the javascript part of it. </p>

答:
For any given array of json input you could map over it and return a string representation for each element.

let input = [
  { name: 'Foo', id: 42 },
  { name: 'Bar', id: 1337 },
  { name: 'Biz', id: 12 }
];

let elems = input.map(e => `<li>${e.name} (${e.id})</li>`);
document.querySelector('#list').innerHTML = elems.join('');```
<pre class="snippet-code-html lang-html prettyprint-override"><code><ul id="list"></ul></code>```

Title: Converting Json data to html?

Body:
Cat Photo Finder

      The message will go here

      <button id = "getMessage" class = "btn btn-primary">
        Get Message
      </button>

So I am an amateur front end developer I just finished some basic JS and started learning about json and jquery but this above bit of code is going over my head.
Could some one please explain the javascript part of it.

Body:
For any given array of json input you could map over it and return a string representation for each element.

let input = [
  { name: 'Foo', id: 42 },
  { name: 'Bar', id: 1337 },
  { name: 'Biz', id: 12 }
];

let elems = input.map(e => `<li>${e.name} (${e.id})</li>`);
document.querySelector('#list').innerHTML = elems.join('');

<ul id="list"></ul>


问:
Cannot free memory of or unload flash swf
I'm using Adobe Animate CC with AS3. I'm having the following problem with my project (which has a lot of animation in it and hence is quite heavy)

There are 4 swf files which are in the same folder. The first one is like a blank container which loads the second swf automatically upon run. The second one has got a few buttons in it along with some animation. When the animation gets over, there is a button that loads the third swf. Now this 3rd swf has got a next button to load the next swf. The 4th swf has got back button to load the previous swf. The 3rd swf has in turn a home button that loads the 2nd swf.
Now, the problem is that when the next button is pressed, say on 2nd swf, not only should the 3rd swf open but the 2nd swf should get unloaded and the memory occupied by it should be freed. And same with the 3rd and the 4th swf.
However, the unloaded swf should open again when the back button is clicked.
If anyone could provide a link to or code for back button and load-unload, that'd be greatly appreciated.

答:
I think it is much easier to load them all at once and then switch their visibility/attachment to the stage. However, if they are indeed too heavy to reside in the memory at once, you need a little trick to load them into a separate ApplicationDomain so they could be removed without anything left behind.

```<code>import flash.display.Loader;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;

var aLoader:Loader = new Loader;

// Loading an SWF so it can be fully unloaded.
aLoader.load(new URLRequest("external.swf"), new LoaderContext(false, new ApplicationDomain));

// Unloading the loaded SWF.
aLoader.unloadAndStop(true);
</code>```

Body:
I think it is much easier to load them all at once and then switch their visibility/attachment to the stage. However, if they are indeed too heavy to reside in the memory at once, you need a little trick to load them into a separate ApplicationDomain so they could be removed without anything left behind.

import flash.display.Loader;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;

var aLoader:Loader = new Loader;

// Loading an SWF so it can be fully unloaded.
aLoader.load(new URLRequest("external.swf"), new LoaderContext(false, new ApplicationDomain));

// Unloading the loaded SWF.
aLoader.unloadAndStop(true);


问:
Return rows with column not equals null
I have a working Spring Boot application, I'm vey new to JPA/Hibernate and I'm trying to retrieve results having one of the fields containing no null values. Right now I am getting everything including nulls.

It is phone_number_id that I don't want it to be null. I added nullable=false but it looks like it has no effect on retrievals.

What do I need to do to get only columns which have no null occurrences of phone_number_id

My Model

```<code>@Entity
@NamedQuery(name="Ad.findAll", query="SELECT a FROM Ad a")
public class Ad implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long id;

    @Column(name="ad_content")
    private String adContent;

    @Column(name="ad_title")
    private String adTitle;

    @Column(name="ad_url")
    private String adUrl;

    private Integer age;

    @Column(name="post_id")
    private Long postId;

    //bi-directional many-to-one association to City
    @ManyToOne
    private City city;

    //bi-directional many-to-one association to PhoneNumber
    @ManyToOne
    @JoinColumn(name="phone_number_id", nullable=false)
    private PhoneNumber phoneNumber;

    //bi-directional many-to-one association to AdPhoto
    @OneToMany(mappedBy="ad")
    private List<AdPhoto> adPhotos;

    public Ad() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAdContent() {
        return this.adContent;
    }

    public void setAdContent(String adContent) {
        this.adContent = adContent;
    }

    public String getAdTitle() {
        return this.adTitle;
    }

    public void setAdTitle(String adTitle) {
        this.adTitle = adTitle;
    }

    public String getAdUrl() {
        return this.adUrl;
    }

    public void setAdUrl(String adUrl) {
        this.adUrl = adUrl;
    }

    public Integer getAge() {
        return this.age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Long getPostId() {
        return this.postId;
    }

    public void setPostId(Long postId) {
        this.postId = postId;
    }

    public City getCity() {
        return this.city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public PhoneNumber getPhoneNumber() {
        return this.phoneNumber;
    }

    public void setPhoneNumber(PhoneNumber phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public List<AdPhoto> getAdPhotos() {
        return this.adPhotos;
    }

    public void setAdPhotos(List<AdPhoto> adPhotos) {
        this.adPhotos = adPhotos;
    }

    public AdPhoto addAdPhoto(AdPhoto adPhoto) {
        getAdPhotos().add(adPhoto);
        adPhoto.setAd(this);

        return adPhoto;
    }

    public AdPhoto removeAdPhoto(AdPhoto adPhoto) {
        getAdPhotos().remove(adPhoto);
        adPhoto.setAd(null);

        return adPhoto;
    }
</code>```

My repository

```<code>@Repository
public interface AdRepository extends PagingAndSortingRepository<Ad, Long> {

}
</code>```

and my Service class

```<code>@Service
public class AdService {
    private final static int PAGESIZE = 3;

    @Autowired
    AdRepository adRepository;

    public Iterable<Ad> findAllAds() {
        return adRepository.findAll();
    }

    public List<Ad> getPage(int pageNumber) {
        PageRequest request = new PageRequest(pageNumber - 1, PAGESIZE, Sort.Direction.ASC, "id");

        return adRepository.findAll(request).getContent();
    }
}
</code>```

答:
In:

```<code>@ManyToOne
@JoinColumn(name="phone_number_id", nullable=false)
private PhoneNumber phoneNumber;
</code>```

the nullable = false specifies the not null constraint on the DB level.

If you also want to validate the content on the application level you cand use the @NotNull annotation (which I also recommend).

By doing this you do not allow a Ad entity to exist without a phone number. If however the phone number is optional, then use the answer provided by @Essex Boy

Title: Return rows with column not equals null

Body:
I have a working Spring Boot application, I'm vey new to JPA/Hibernate and I'm trying to retrieve results having one of the fields containing no null values. Right now I am getting everything including nulls.

It is phone_number_id that I don't want it to be null. I added nullable=false but it looks like it has no effect on retrievals.

What do I need to do to get only columns which have no null occurrences of phone_number_id

My Model

@Entity
@NamedQuery(name="Ad.findAll", query="SELECT a FROM Ad a")
public class Ad implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long id;

    @Column(name="ad_content")
    private String adContent;

    @Column(name="ad_title")
    private String adTitle;

    @Column(name="ad_url")
    private String adUrl;

    private Integer age;

    @Column(name="post_id")
    private Long postId;

    //bi-directional many-to-one association to City
    @ManyToOne
    private City city;

    //bi-directional many-to-one association to PhoneNumber
    @ManyToOne
    @JoinColumn(name="phone_number_id", nullable=false)
    private PhoneNumber phoneNumber;

    //bi-directional many-to-one association to AdPhoto
    @OneToMany(mappedBy="ad")
    private List<AdPhoto> adPhotos;

    public Ad() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAdContent() {
        return this.adContent;
    }

    public void setAdContent(String adContent) {
        this.adContent = adContent;
    }

    public String getAdTitle() {
        return this.adTitle;
    }

    public void setAdTitle(String adTitle) {
        this.adTitle = adTitle;
    }

    public String getAdUrl() {
        return this.adUrl;
    }

    public void setAdUrl(String adUrl) {
        this.adUrl = adUrl;
    }

    public Integer getAge() {
        return this.age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Long getPostId() {
        return this.postId;
    }

    public void setPostId(Long postId) {
        this.postId = postId;
    }

    public City getCity() {
        return this.city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public PhoneNumber getPhoneNumber() {
        return this.phoneNumber;
    }

    public void setPhoneNumber(PhoneNumber phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public List<AdPhoto> getAdPhotos() {
        return this.adPhotos;
    }

    public void setAdPhotos(List<AdPhoto> adPhotos) {
        this.adPhotos = adPhotos;
    }

    public AdPhoto addAdPhoto(AdPhoto adPhoto) {
        getAdPhotos().add(adPhoto);
        adPhoto.setAd(this);

        return adPhoto;
    }

    public AdPhoto removeAdPhoto(AdPhoto adPhoto) {
        getAdPhotos().remove(adPhoto);
        adPhoto.setAd(null);

        return adPhoto;
    }

My repository

@Repository
public interface AdRepository extends PagingAndSortingRepository<Ad, Long> {

}

and my Service class

@Service
public class AdService {
    private final static int PAGESIZE = 3;

    @Autowired
    AdRepository adRepository;

    public Iterable<Ad> findAllAds() {
        return adRepository.findAll();
    }

    public List<Ad> getPage(int pageNumber) {
        PageRequest request = new PageRequest(pageNumber - 1, PAGESIZE, Sort.Direction.ASC, "id");

        return adRepository.findAll(request).getContent();
    }
}

Body:
In:

@ManyToOne
@JoinColumn(name="phone_number_id", nullable=false)
private PhoneNumber phoneNumber;

the nullable = false specifies the not null constraint on the DB level.

If you also want to validate the content on the application level you cand use the @NotNull annotation (which I also recommend).

By doing this you do not allow a Ad entity to exist without a phone number. If however the phone number is optional, then use the answer provided by @Essex Boy


问:
ng-repeat doesn't expose array element (angularJS 1.6.6)
having a problem where ng-repeat doesn't render the array element usable variable.

eg :

```<code><li ng-repeat="i in [0,1,2,3,4]">{{i}}</li>
</code>```

should render something like:

```<code><li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</code>```

But I get:

```<code><li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</code>```

答:
Your code is working. Maybe something in another place is wrong.

{{i}}

```

Body:
having a problem where ng-repeat doesn't render the array element usable variable.

eg :

{{i}}

should render something like:

0

1

2

3

4

But I get:

Body:
Your code is working. Maybe something in another place is wrong.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
   <ul>
      <li ng-repeat="i in [0,1,2,3,4]">{{i}}</li>
   </ul>
</body>


问:
Error:error: '__ANDROID_API__' macro redefined [-Werror,-Wmacro-redefined] -Android Studio
I'm getting this error, in a project where I have used below modules of "AndEngine",

1) andEngine
2) andEnginePhysicsBox2DExtension
3) andEngineTexturePackerExtension

Previously(2 - 3 months back), the Project was executing properly. And now, when I tried to execute the code, I'm facing this error.

When I tried to comment the "LOCAL_CFLAGS:= -Werror" line, from "Android.mk" of "andEngine" module then I got the error as below,

```<code>[armeabi-v7a] Compile++ arm  : andenginephysicsbox2dextension <= b2PolygonAndCircleContact.cpp
In file included from <built-in>:346:
<command line>:6:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
#define __ANDROID_API__ 14
        ^
<built-in>:338:9: note: previous definition is here
#define __ANDROID_API__ 9
        ^
error: error opening 'C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o.d': No such file or directory
1 warning and 1 error generated.
make: *** [C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o] Error 1
</code>```

FYI...
Android Studio : 2.3.3.
NDK : Is up-to-date.

Thanks in Advance.

答:
After long research, finally got the solution.

All you got to do is,

1) In the "Android.mk" file of "andEngine", replace the line with "LOCAL_CFLAGS := -Werror" with "LOCAL_CFLAGS := -w". Where, "-Werror" shows warnings as it is an error and "-w" suppresses all the warnings(which are not actual errors) related to "andEngine" and other modules.

2) Kindly clean the project and it should work in most of the cases. In case, you still have some error(s) then follow the step 3.

3) You now have to delete the "jniLibs" folder present in "andEngine\src\main\" path(Or the path of folder mention in place of "andEngine" in that error)  and recompile the code.

Error:Execution failed for task ':andEngine:transformNativeLibsWithMergeJniLibsForDebug'.
  More than one file was found with OS independent path 'lib/x86/libandengine.so'

And thank you all for your comments/suggestions.

Body:
I'm getting this error, in a project where I have used below modules of "AndEngine",

1) andEngine
2) andEnginePhysicsBox2DExtension
3) andEngineTexturePackerExtension

Previously(2 - 3 months back), the Project was executing properly. And now, when I tried to execute the code, I'm facing this error.

When I tried to comment the "LOCAL_CFLAGS:= -Werror" line, from "Android.mk" of "andEngine" module then I got the error as below,

[armeabi-v7a] Compile++ arm  : andenginephysicsbox2dextension <= b2PolygonAndCircleContact.cpp
In file included from <built-in>:346:
<command line>:6:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
#define __ANDROID_API__ 14
        ^
<built-in>:338:9: note: previous definition is here
#define __ANDROID_API__ 9
        ^
error: error opening 'C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o.d': No such file or directory
1 warning and 1 error generated.
make: *** [C:/Users/.../andEnginePhysicsBox2DExtension/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/andenginephysicsbox2dextension/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o] Error 1

FYI...
Android Studio : 2.3.3.
NDK : Is up-to-date.

Thanks in Advance.


问:
UnresolvedUserTypeException: cannot resolve user type
I have a case class like this:

```<code>case class Address(id String, location String)
case class Person(id String, name String, address Option[Address])
</code>```

Now I want to store these case class in cassandra table. I am working with Lagom Persistence. So I created Read side Processor to do that task. I wrote the following under setGlobalPrepare method:

```<code>session.executeWrite("""
| CREATE TYPE Address(
| id text,
| location text)""".stripMargin)

session.executeCreateTable("""
| CREATE TABLE Person(
| id text,
| name text,
| address frozen<Address>,
| PRIMARY KEY((id),name)
| )""".stripMargin)
</code>```

But this showing an error that "UnresolvedUserTypeException: cannot resolve user type testdatabase.id" (testdatabase is the keyspace)and same for name of Address UDT.

First i Thought it was because of all the execution of the command are running in future so I tried using map to wait for the main table to be created before the UDT but didnt work. All tables are showing in cassandra but i am getting this error and i am not able to insert anything to it.

Need Help....

答:
the type creation should also be invoked within a "executeCreateTable" and you should add a space between "frozen" and the UDT-Name.

```<code>session.executeCreateTable("""
   CREATE TYPE IF NOT EXISTS Address(
        id text,
        location text
   )"""
)
session.executeCreateTable("""
    CREATE TABLE IF NOT EXISTS Person(
        id text,
        name text,
        address frozen <Address>,
        PRIMARY KEY((id),name)
    )"""
)
</code>```

Hope that helps/works.

Regards

Body:
I have a case class like this:

case class Address(id String, location String)
case class Person(id String, name String, address Option[Address])

Now I want to store these case class in cassandra table. I am working with Lagom Persistence. So I created Read side Processor to do that task. I wrote the following under setGlobalPrepare method:

session.executeWrite("""
| CREATE TYPE Address(
| id text,
| location text)""".stripMargin)

session.executeCreateTable("""
| CREATE TABLE Person(
| id text,
| name text,
| address frozen<Address>,
| PRIMARY KEY((id),name)
| )""".stripMargin)

But this showing an error that "UnresolvedUserTypeException: cannot resolve user type testdatabase.id" (testdatabase is the keyspace)and same for name of Address UDT.

First i Thought it was because of all the execution of the command are running in future so I tried using map to wait for the main table to be created before the UDT but didnt work. All tables are showing in cassandra but i am getting this error and i am not able to insert anything to it.

Need Help....

Body:
the type creation should also be invoked within a "executeCreateTable" and you should add a space between "frozen" and the UDT-Name.

session.executeCreateTable("""
   CREATE TYPE IF NOT EXISTS Address(
        id text,
        location text
   )"""
)
session.executeCreateTable("""
    CREATE TABLE IF NOT EXISTS Person(
        id text,
        name text,
        address frozen <Address>,
        PRIMARY KEY((id),name)
    )"""
)

Hope that helps/works.

Regards


问:
Configure a SQL Server Instance as (local)
Each member of our development team has a copy of our application's database running on a local version of SQL Server 2008 Enterprise with SP1. Everyone is able to access the database by specifying their server and instance name in their web.config file, but to best share the developer version of our web.config file, we have standardized on making connections strings generic by using integrated security and setting server property to (local). This strategy is working fine for the majority of our 64-bit Windows 7 machines but in few cases (local) isn't recognized. We have compared settings via the SQL Server Configuration Manager (namely ensuring that the named pipes protocol was enabled) and we've tried setting the "(local)" alias via SQL Server Client Network Utility, but we haven't any luck. What needs to be done in order to use (local) in our connections strings? </p>

答:
Trying changing the Pipe Name for your instance to "\.\pipe\sql\query".

You can find that setting by starting SQL Server Configuration Manager, and navigating to SQL Server Network Configuration > Protocols for (Instance Name) and right-clicking on Named Pipes and selecting Properties. If Named Pipes is not enabled, be sure to enable it before restarting the SQL Server service (see comment by @NoahHeldman).

When connecting to the default instance (that is, without an instance name), SQL Server uses the default port of 1433 and the default pipe name of "\.\pipe\sql\query". Changing it back to match should (hopefully) fix it.


问:
Php search in database to show data, not working
i'm trying to display some data from my database, and i dosen't work when i try to display some of the data, specified by a search bar. Here is the code. I hope someone can fix my problem.

Ive tried for a few hours, but nothing seems to work.

I removed most of the html code, to even be able to post.

<?php
 include_once 'includes/dbh.inc.php';
?>
<!DOCTYPE html>

    <form>
    <input type="text" name="search" placeholder="Search for graphicscard"/>
    <input type="submit" value="Search" />

<?php

?>

    </form>

Graphicscard
Coin
Hashrate
Bios-modded
Core-clock
Memory-clock
Power draw
Additional info

      <?
  if(isset($_POST['search'])) {
        $searchq = $_POST['search'];
        $searchq = preg_replace("#[^`0-9a-z]#i","", $searchq);

        $query = mysqli_query("SELECT * FROM 'cards' WHERE 'name' LIKE '$search%' OR coin LIKE '$search%'") or die ("No results");
        $count = mysqli_num_rows($queryQ);

            while ($row = mysqli_fetch_array($query)) {
                echo "
";
                echo "".$row['name']."	";
                echo "".$row['coin'] . "	";
                echo "".$row['hashrate'] . "	";
                echo "".$row['bios_mod'] . "	";
                echo "".$row['core_clock'] . "	";
                echo "".$row['memory_clock'] . "	";
                echo "".$row['power_draw'] . "	";
                echo "".$row['additional_info'] . "	";
                echo "
";
            }
        }

        ?>```

答: You are using $search in the query, but the correct variable should be $searchq .


问:
Jelastic phpmyadmin
I am trying out the jelastic platform to run wordpress on.  In the past I have used a VPS to do this and then use SSH to do anything on my database.

I notice that the platform gives you Phpmyadmin to do mysql administration and as this only asks for a username and password, isn't this a security issue?

Is there a way to either disable the phpmyadmin portal or at least firewall access to this, so only my ip address can access the portal?

答:
You are right to a point - it can be a security issue. This is one case where it's a trade between convenience and security: you must decide what is the right balance for your particular use case.

Jelastic gives you access to the Apache config on the MySQL node (so you can configure HTTP auth, or IP based restrictions - or even disable phpMyAdmin entirely if you don't need it). You also have the ability to customise the firewall rules (e.g. to restrict phpMyAdmin access to your own office IP address).

One note about the firewall rules - unless you add public IP to your MySQL node (not recommended), you will be accessing via the Jelastic resolver (shared proxy) so you cannot selectively block this way (the IP that connects to phpMyAdmin is the proxy, not your office IP).

I recommend to consult with your provider's support team to get exact assistance for your particular needs.

Title: Jelastic phpmyadmin


问:
Hiding play button initially
How would I hide the Playbutton when viewing the cover image, and show it after you click on the image?

I've been trying different ways, but can't seem to get it.

Full Code:

https://jsfiddle.net/0yxvpa09/12/

Click on the image to reveal a grid

Screenshot

```<code><div class="playButton ">

  <svg class="play" style="margin:5px 9px;" width="38" height="40" viewbox="0 0 85 100">
    <path d="M81 44.6c5 3 5 7.8 0 10.8L9 98.7c-5 3-9 .7-9-5V6.3c0-5.7 4-8 9-5l72 43.3z"></path>
  </svg>

  <svg class="pause" style="display: none;margin:5px 7px;" width="36" height="40" viewbox="0 0 60 100">
    <path d="M0 8c0-5 3-8 8-8s9 3 9 8v84c0 5-4 8-9 8s-8-3-8-8V8zm43 0c0-5 3-8 8-8s8 3 8 8v84c0 5-3 8-8 8s-8-3-8-8V8z"></path>
  </svg>

<script>
  (function iife() {
    "use strict";

    function hideClickedElement(evt) {
      var target = evt.target;
      target.classList.add("hide");
      document.querySelector(".test").classList.remove("hide");
    }
    var cover = document.querySelector(".cover");
    cover.addEventListener("click", hideClickedElement, false);
  }());

</script>
</code>```

答:
add

position:absolute;

z-index:999;

to your .cover class

and than added

position:absolute;

z-index:1;

to your .playButton class.

Title: Hiding play button initially

Body:
How would I hide the Playbutton when viewing the cover image, and show it after you click on the image?

I've been trying different ways, but can't seem to get it.

Full Code:

https://jsfiddle.net/0yxvpa09/12/

Click on the image to reveal a grid

Screenshot

  <svg class="play" style="margin:5px 9px;" width="38" height="40" viewbox="0 0 85 100">
    <path d="M81 44.6c5 3 5 7.8 0 10.8L9 98.7c-5 3-9 .7-9-5V6.3c0-5.7 4-8 9-5l72 43.3z"></path>
  </svg>

  <svg class="pause" style="display: none;margin:5px 7px;" width="36" height="40" viewbox="0 0 60 100">
    <path d="M0 8c0-5 3-8 8-8s9 3 9 8v84c0 5-4 8-9 8s-8-3-8-8V8zm43 0c0-5 3-8 8-8s8 3 8 8v84c0 5-3 8-8 8s-8-3-8-8V8z"></path>
  </svg>


问:
Finding All Insecure Content on a Secure Page
What's the most efficient way to find a list of all non-HTTPS URLs requested by an HTTPS page? If this kind of security violation happens, every browser alerts the user, but I can't find an easy way to find what exact URLs cause the violation.

The easiest way I've found so far is to use Firefox, but even then it's still not very convenient. First, I can right-click, select View Page Info, click the Media tab, and scroll through a list of URLs. However, this seems to only list image files, not CSS or JS includes that can also cause the error. For those, I have to use the Firebug extension, select the Net tab, and manually hover my mouse over each item to see the entire URL. Unfortunately, this can take a while if you have dozens of media files. Is there a better way?

答:
Use Fiddler.

Secure requests won't show up at all (except as HTTPS CONNECTs, which can be hidden), so everything you'll see is bad.


问:
Shopify Day wise show different collection in single product page
How can we show different day wise different collections on shopify single product page.

If any one know solutions for this then please update me.

Thanks,
Ketan.

答: You need to go for the private app in that app we can show the day wise different collections using the Tag  </p>


问:
How to generate unique int id using counting technique?
I have the following class that creates some comment and save it to dynamo db that must contain unique comment id. How to "implement" counting - a simple counter that will create the unique id for a comment. I don't want to repeat rsu_id value.

```<code>class RsuService(object):
    next_id = 0

    def __init__(self):
        self.rsu_id = RsuService.next_id
        RsuService.next_id += 1

    async def create(self, alert_id, text):
        message = {
            'event_id': alert_id,
            'text': text,
            'is_rsu': True,
            'comment_id': self.rsu_id
        }
        await save(message)
</code>```

Is it good implementation? How to improve it?

答:
I think it is a good implementation, if you don't have cases of concurrent operations with RsuService class.

But it may fail in case two or more objects of the RsuService are created at the same time. Beacuse += operations is not atomic in python.

I would suggest you to this if you have case of concurrent operations.

```<code>import threading
class RsuService(object):
    next_id = 0
    lock = threading.Lock() #lock shared by all objects of this class

def __init__(self):
    lock.acquire()
    self.rsu_id = RsuService.next_id
    RsuService.next_id += 1
    lock.release()
</code>```

And if you don't have cases of concurrent tasks, it would be better to use timestamp as unique id, because if you restart the program your counter will start from beginning which will be an issue.

```<code>import time
...
RsuService.next_id = time.time()
</code>```

Body:
I have the following class that creates some comment and save it to dynamo db that must contain unique comment id. How to "implement" counting - a simple counter that will create the unique id for a comment. I don't want to repeat rsu_id value.

class RsuService(object):
    next_id = 0

    def __init__(self):
        self.rsu_id = RsuService.next_id
        RsuService.next_id += 1

    async def create(self, alert_id, text):
        message = {
            'event_id': alert_id,
            'text': text,
            'is_rsu': True,
            'comment_id': self.rsu_id
        }
        await save(message)

Is it good implementation? How to improve it?

Body:
I think it is a good implementation, if you don't have cases of concurrent operations with RsuService class.

But it may fail in case two or more objects of the RsuService are created at the same time. Beacuse += operations is not atomic in python.

I would suggest you to this if you have case of concurrent operations.

import threading
class RsuService(object):
    next_id = 0
    lock = threading.Lock() #lock shared by all objects of this class

def __init__(self):
    lock.acquire()
    self.rsu_id = RsuService.next_id
    RsuService.next_id += 1
    lock.release()

And if you don't have cases of concurrent tasks, it would be better to use timestamp as unique id, because if you restart the program your counter will start from beginning which will be an issue.

import time
...
RsuService.next_id = time.time()


问:
JAX-RS (Jersey): String from JSON request body still escaped
This is driving me crazy. I'm working on a REST endpoint in JAX-RS (Glassfish / Jersey). I have a method that's supposed to receive a String, store it and return it. The entire endpoint should consume and produce JSON. But every time I post a String to the method, it's handed to me in escaped form. E.g. if I post:

```<code>fetch("http://localhost:8080/myapp/rest/myresource", {
  method: "post",
  credentials: 'same-origin',
  body: JSON.stringify("test\ntest"),
  headers: {
    "Content-Type": "application/json"
  }
})
</code>```

and the resource is:

```<code>@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class MyResource {

    @POST
    public String set(@NotNull String value){
        // store it
        return storedValue;
    }
}
</code>```

then what is stored, and return to the client, is:

```<code>"test\ntest"
</code>```

If, however, I wrap the String in an object:

```<code>fetch("http://localhost:8080/myapp/rest/myresource", {
  method: "post",
  credentials: 'same-origin',
  body: JSON.stringify({value: "test\ntest"}),
  headers: {
    "Content-Type": "application/json"
  }
})
</code>```

with resource

```<code>@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class MyResource {

    @XmlRootElement
    public static class Wrapper {
        public String value;
    }

    @POST
    public String set(@NotNull Wrapper wrapper) {
        String value = wrapper.value;
        // store it
        return storedValue;
    }
}
</code>```

then the value that's stored and returned to the client is

```<code>test
test
</code>```

Am I missing something?

```<code>Glassfish 4.1.1
 - jersey 2.10.4-0
 - json 1.0-0.1
</code>```

答:
In order to post raw String as JSON using JAX-RS, you can use "@JsonRawValue" provided by fasterxml.jackson

```<code>Class ResponseObject {

@JsonRawValue
String jsonString;
...
}
</code>```

Whenever you send the response object, unescaped json is sent without slashes.

Body:
This is driving me crazy. I'm working on a REST endpoint in JAX-RS (Glassfish / Jersey). I have a method that's supposed to receive a String, store it and return it. The entire endpoint should consume and produce JSON. But every time I post a String to the method, it's handed to me in escaped form. E.g. if I post:

fetch("http://localhost:8080/myapp/rest/myresource", {
  method: "post",
  credentials: 'same-origin',
  body: JSON.stringify("test\ntest"),
  headers: {
    "Content-Type": "application/json"
  }
})

and the resource is:

@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class MyResource {

    @POST
    public String set(@NotNull String value){
        // store it
        return storedValue;
    }
}

then what is stored, and return to the client, is:

"test\ntest"

If, however, I wrap the String in an object:

fetch("http://localhost:8080/myapp/rest/myresource", {
  method: "post",
  credentials: 'same-origin',
  body: JSON.stringify({value: "test\ntest"}),
  headers: {
    "Content-Type": "application/json"
  }
})

with resource

@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class MyResource {

    @XmlRootElement
    public static class Wrapper {
        public String value;
    }

    @POST
    public String set(@NotNull Wrapper wrapper) {
        String value = wrapper.value;
        // store it
        return storedValue;
    }
}

then the value that's stored and returned to the client is

test
test

Am I missing something?

Glassfish 4.1.1
 - jersey 2.10.4-0
 - json 1.0-0.1

Body:
In order to post raw String as JSON using JAX-RS, you can use "@JsonRawValue" provided by fasterxml.jackson

Class ResponseObject {

@JsonRawValue
String jsonString;
...
}

Whenever you send the response object, unescaped json is sent without slashes.


问:
How to define calculations in a data frame depending on values from another data frame?
I have to calculate a coefficient based on a dataset stored in a data frame (A) of size 4936 obs. x 1025 var.

In a first row [1,] time in seconds is presented, each row is a sample collected from a different place. A sample of the data frame A:

```<code>#        V1   V2   V3   V4
# [1,] 26.4 26.5 26.6 26.7
# [2,]  -15   -5    2    3
# [3,]    6   -7    5    8
# [4,]    9    4    4   -2
</code>```

In another data frame (B) I stored the time from which I should start my calculations for each row in A. An example of the data frame B:

```<code>#      time
# [1,] 26.4
# [2,] 26.6
# [3,] 26.5
</code>```

Let's simplify that the coefficient is a sum of the data collected in one place (data frame A), depending on the time of their collection (data frame B). For the example above, the calculation should work like this:

```<code>sum1=-15+(-5)+2+3
sum2=5+8
sum3=4+4+(-2)
</code>```

The results of the calculations I would like to store in a new data frame, which would look like this:

```<code>#       Sum
# [1,]  -15
# [2,]   13
# [3,]    6
</code>```

How to link the calculations between the two data frames depending on a value stored in the second data frame?

答:
Solution using sapply to iterate and select columns depending on time of collection:

```<code># Time from original table
foo <- df1[1, ]
# Time from table B
time <- c(26.4, 26.6, 26.5)

# Remove time row from original table
df1 <- df1[-1, ]

# Iterate over and select columns with foo >= time
sapply(1:length(time), function(x)
    sum(df1[x, which(foo >= time[x])])
)

# [1] -15  13   6
</code>```

Body:
I have to calculate a coefficient based on a dataset stored in a data frame (A) of size 4936 obs. x 1025 var.

In a first row [1,] time in seconds is presented, each row is a sample collected from a different place. A sample of the data frame A:

#        V1   V2   V3   V4
# [1,] 26.4 26.5 26.6 26.7
# [2,]  -15   -5    2    3
# [3,]    6   -7    5    8
# [4,]    9    4    4   -2

In another data frame (B) I stored the time from which I should start my calculations for each row in A. An example of the data frame B:

#      time
# [1,] 26.4
# [2,] 26.6
# [3,] 26.5

Let's simplify that the coefficient is a sum of the data collected in one place (data frame A), depending on the time of their collection (data frame B). For the example above, the calculation should work like this:

sum1=-15+(-5)+2+3
sum2=5+8
sum3=4+4+(-2)

The results of the calculations I would like to store in a new data frame, which would look like this:

#       Sum
# [1,]  -15
# [2,]   13
# [3,]    6

How to link the calculations between the two data frames depending on a value stored in the second data frame?

Body:
Solution using sapply to iterate and select columns depending on time of collection:

# Time from original table
foo <- df1[1, ]
# Time from table B
time <- c(26.4, 26.6, 26.5)

# Remove time row from original table
df1 <- df1[-1, ]

# Iterate over and select columns with foo >= time
sapply(1:length(time), function(x)
    sum(df1[x, which(foo >= time[x])])
)

# [1] -15  13   6


问:
How to get the options inside ng-select in angular2 or typescript
i have installed angular2-select and have defined that in module.ts as well. But when i click on select button, there are 2 contents but the contents are not visible, can anyone help me to solve this.

HTML:

```<code><div class="form-group">
<label >Category Type</label>
<ng-select [options]="category" [(ngModel)]="category.name" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>
 </div>
</code>```

ts:
category:any = [{name:'school'},{name:'college'}];

答:
According to angular-2 select, the options take in items array

Also, use ng-2 select instead of angular-2 select

```<code>import {SelectModule} from 'ng2-select'
</code>```

According to its documentation here, official documentation it requires,

items - (Array<any>) - Array of items from which to select. Should be an array of objects with id and text properties. As convenience, you may also pass an array of strings, in which case the same string is used for both the ID and the text.

So, your object shoud be either,

```<code>category:any = [{ id: 'school', text:'school'},{id: 'college', text:'college'}];

<ng-select [items]="category" [(ngModel)]="category.id" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>

or

category:any = ['school', 'college'];

<ng-select [items]="category" [(ngModel)]="category" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>
</code>```

PS: You can use angular2-select change the object to,

```<code>import {SelectModule} from 'angular2-select'
</code>```

It uses, value and label and use same [options] in html

```<code>category:any = [{ label: 'school', value:'school'},{label: 'college', value:'college'}];

<ng-select [options]="category" [(ngModel)]="category.label" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>
</code>```

Body:
i have installed angular2-select and have defined that in module.ts as well. But when i click on select button, there are 2 contents but the contents are not visible, can anyone help me to solve this.

HTML:

Category Type
<ng-select [options]="category" [(ngModel)]="category.name" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>

ts:
category:any = [{name:'school'},{name:'college'}];

Body:
According to angular-2 select, the options take in items array

Also, use ng-2 select instead of angular-2 select

import {SelectModule} from 'ng2-select'

According to its documentation here, official documentation it requires,

items - (Array<any>) - Array of items from which to select. Should be an array of objects with id and text properties. As convenience, you may also pass an array of strings, in which case the same string is used for both the ID and the text.

So, your object shoud be either,

category:any = [{ id: 'school', text:'school'},{id: 'college', text:'college'}];

<ng-select [items]="category" [(ngModel)]="category.id" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>

or

category:any = ['school', 'college'];

<ng-select [items]="category" [(ngModel)]="category" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>

PS: You can use angular2-select change the object to,

import {SelectModule} from 'angular2-select'

It uses, value and label and use same [options] in html

category:any = [{ label: 'school', value:'school'},{label: 'college', value:'college'}];

<ng-select [options]="category" [(ngModel)]="category.label" name="category" class='filterDropDown' placeholder="Category" notFoundMsg="No Category Found">
 </ng-select>