问:
Add Linear Layout Dynamically inside the List item?
I am not able to use List within the list so i jump to add the Dynamic Linear Layout to be Added inside the ListItems.I want to show the list which contains many textview and below the textview i want to display Another listview.So i switch to add Linear Layout dynamically within the parent list.

xml

```<code><LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/linear_receipt1_fee"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#008b8b"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/student_profile_fee_ReceiptIssuedDate"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="6dp"
                    android:text="Date"
                    android:textColor="#fff"
                    android:textStyle="bold" />

                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#FFFFFF" />

                <TextView
                    android:id="@+id/student_profile_fee_ReceiptIssuedNumber"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="6dp"
                    android:text="Receipt number"
                    android:textColor="#fff"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/receipt1_fee"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#A4ACB0"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center_horizontal"
                        android:padding="5dp"
                        android:text="Description"
                        android:textSize="12dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center_horizontal"
                        android:padding="5dp"
                        android:text="Amount (Nrs) "
                        android:textSize="12dp"
                        android:textStyle="bold">

                    </TextView>

                </LinearLayout>

**how can this linear layout be repeatedly added inside the list items**
                <LinearLayout
                    android:id="@+id/student_profile_fee_linearlayout1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/student_profile_fee_description"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left|center"
                        android:paddingLeft="70dp"
                        android:paddingTop="10dp"
                        android:text="Sports"
                        android:textSize="10dp" />

                    <TextView
                        android:id="@+id/student_profile_fee_amount"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left|center"
                        android:paddingLeft="70dp"
                        android:paddingTop="10dp"
                        android:text="1000"
                        android:textSize="10dp" />
                </LinearLayout>    **end here **
 <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Total"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="552"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Status"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/student_profile_fee_status"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Paid"
                        android:textColor="#108B89"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Received Date"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/student_profile_fee_FeeReceiptDate"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="9 March,2017"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>
            </LinearLayout>

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#fff" />
   </LinearLayout>
</code>```

CustomFeeListStudentAdapter

```<code>public class CustomFeeListStudentAdapter extends BaseAdapter {
    LinearLayout reciptViewDynamic;

    Context mContext;
    Fee fee = new Fee();

    ArrayList<StudentFeeInformation> student_list;

    LinearLayout linearLayout;

    String TAG = "HomeTab_adapter";

    public CustomFeeListStudentAdapter(Context mContext, ArrayList<StudentFeeInformation> student_list) {
        super();
        this.mContext = mContext;
        this.student_list = student_list;
    }

    @Override
    public int getCount() {

        System.out.println(student_list.size());
        return student_list.size();
    }

    @Override
    public Object getItem(int arg0) {
        return student_list.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(final int postion, View convertView, ViewGroup parent) {
        final Holder viewHolder;

        if (convertView == null) {
            // inflate the layout
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.fragment_fee, parent, false);

            // well set up the ViewHolder
            viewHolder = new Holder();
            viewHolder.student_profile_fee_status = (TextView) convertView.findViewById(R.id.student_profile_fee_status);
            viewHolder.student_profile_ReceiptIssuedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedDate);
            viewHolder.student_profile_ReceiptIssuedNumber = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedNumber);
            viewHolder.student_profile_FeeReceivedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_FeeReceiptDate);
            // viewHolder.student_profile_Fee_Amount = (TextView) convertView.findViewById(R.id.student_profile_fee_amount);
            // viewHolder.student_profile_Fee_Description = (TextView) convertView.findViewById(R.id.student_profile_fee_description);

            //added code
            viewHolder.receiptLinearLayout = (LinearLayout) convertView.findViewById(R.id.recipt_layout);

        } else {
            // we've just avoided calling findViewById() on resource everytime
            // just use the viewHolder
            viewHolder = (Holder) convertView.getTag();
        }

        Log.d(TAG, "@@ postion:" + postion + " getFeeDescription" + student_list.get(postion).getFeeDescription());
        Log.d(TAG, "@@ postion:" + postion + " getAmount" + student_list.get(postion).getAmount());

        viewHolder.student_profile_fee_status.setText(student_list.get(postion).getStatus());
        viewHolder.student_profile_ReceiptIssuedDate.setText(student_list.get(postion).getReceiptIssuedDate());
        viewHolder.student_profile_ReceiptIssuedNumber.setText(student_list.get(postion).getReceiptIssuedNumber());
        viewHolder.student_profile_FeeReceivedDate.setText(student_list.get(postion).getFeeReceivedDate());
        //  viewHolder.student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
        // viewHolder.student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());

        //added code
        for (int i = 0; i < 1; i++) {

            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            //   reciptViewDynamic = (LinearLayout) inflater.inflate(R.layout.layout_bil_info, null);

            reciptViewDynamic = (LinearLayout) inflater.inflate(R.layout.layout_bil_info, parent, false);
            viewHolder.student_profile_Fee_Amount = (TextView) reciptViewDynamic.findViewById(R.id.student_profile_fee_amount);
            viewHolder.student_profile_Fee_Description = (TextView) reciptViewDynamic.findViewById(R.id.student_profile_fee_description);
            viewHolder.student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
            viewHolder.student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());

            viewHolder.receiptLinearLayout.addView(reciptViewDynamic);
            viewHolder.receiptLinearLayout.removeAllViews();

        }

        convertView.setTag(viewHolder);
        return convertView;
    }

    class Holder {
        TextView student_profile_fee_status;
        TextView student_profile_ReceiptIssuedDate;
        TextView student_profile_ReceiptIssuedNumber;
        TextView student_profile_FeeReceivedDate;
        TextView student_profile_Fee_Amount;
        TextView student_profile_Fee_Description;
        LinearLayout receiptLinearLayout;

    }

}
</code>```

Fee

```<code>  public class Fee extends Fragment /*implements View.OnClickListener   */ {

    LinearLayout receipt1, receipt2, receipt3, receipt4;
    LinearLayout receipt1detail, receipt2detail, receipt3detail, receipt4detail;
    LinearLayout DescriptionAmount;

    TextView statustextView, feedescription, feeamount;
    ListView listViewfees, listviewfeedetail;
    List<StudentFeeInformation> yourData = new ArrayList<StudentFeeInformation>();

    public static final String Navigation_URL = "http://192.168.100.5:84/Api/financeApi/getAllFees";
    String Amount;
    String Descriptionlist, status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate;
    ArrayList arrayList = new ArrayList();
    String master_id;

    LinearLayout linearLayout;
    TextView textView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.student_fees_listview, container, false);
        inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // view1 = inflater.inflate(R.layout.student_fees_description_data, null);

        setHasOptionsMenu(true);
        receipt1 = (LinearLayout) view.findViewById(R.id.linear_receipt1_fee);

        //  receipt4 = (LinearLayout) view.findViewById(R.id.linear_receipt4_fee);

        //  receipt1detail = (LinearLayout) view.findViewById(R.id.receipt1_fee);
        //  receipt2detail = (LinearLayout) view.findViewById(R.id.receipt2_fee);
        //  receipt3detail = (LinearLayout) view.findViewById(R.id.receipt3_fee);
        //  receipt4detail = (LinearLayout) view.findViewById(R.id.receipt4_fee);

        //   receipt1.setOnClickListener(this);
        //   receipt2.setOnClickListener(this);
        //   receipt3.setOnClickListener(this);
        //   receipt4.setOnClickListener(this);

        //   receipt1detail.setVisibility(View.VISIBLE);
        //   receipt2detail.setVisibility(View.GONE);
        //   receipt3detail.setVisibility(View.GONE);
        //   receipt4detail.setVisibility(View.GONE);

        statustextView = (TextView) view.findViewById(R.id.student_profile_fee_status);
        SessionManagement sessionManagement = new SessionManagement(getContext());
        master_id = sessionManagement.getMasterId();
        listViewfees = (ListView) view.findViewById(R.id.list_student_fees);
        // listviewfeedetail = (ListView) view.findViewById(R.id.listtest);

        //  DescriptionAmount = (LinearLayout) view.findViewById(R.id.student_profile_fee_linearlayout1);
        // DescriptionAmount.addView(view);

        linearLayout = (LinearLayout) view.findViewById(R.id.student_profile_fee_linearlayout1);
        //   v = (LinearLayout)( view.inflate(getContext(), R.layout.student_fees_description_data, null));
        //  linearLayout.addView(view);

        feedescription = (TextView) view.findViewById(R.id.student_profile_fee_description);
        feeamount = (TextView) view.findViewById(R.id.student_profile_fee_amount);

        textView = (TextView) view.findViewById(R.id.student_profile_fee_amount);

        getUsersListData();

        return view;
    }

    private void getUsersListData() {

        String URL = Navigation_URL + "?id=" + master_id + "&fromDate=" + "&toDate=";
        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<StudentFeeInformation> student_list = new ArrayList<>();
                            ArrayList<ArrayList> student_list_description = new ArrayList<>();

                            JSONArray jArray = new JSONArray(response);

                            //  studentFeeInformation = new StudentFeeInformation(response);
                            for (int i = 0; i < jArray.length(); i++) {
                                JSONObject jsonObject = jArray.getJSONObject(i);

                                status = jsonObject.getString("Status");
                                DateofReceiptIssued = jsonObject.getString("DateOfReciept").substring(0, 10);
                                ReceiptNumber = jsonObject.getString("RecieptNo");
                                FeeReceivedDate = jsonObject.getString("recivedDate").substring(0, 10);

                                String Description = jsonObject.getString("Description");
                                JSONArray jArray1 = new JSONArray(Description);

                                //
                                for (int j = 0; j < jArray1.length(); j++) {

                                    JSONObject jsonObjectinner = jArray1.getJSONObject(j);
                                    Descriptionlist = jsonObjectinner.getString("des");
                                    Amount = jsonObjectinner.getString("Amount");
                                    arrayList.add(Descriptionlist);
                                    Log.d("ArrayList", String.valueOf(arrayList));
                                    student_list.add(new StudentFeeInformation(Descriptionlist, Amount));

                                }
                                student_list.add(new StudentFeeInformation(status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate));

                            }

                            System.out.println("student_list size:" + student_list.size());
                            CustomFeeListStudentAdapter customFeeListStudentAdapter = new CustomFeeListStudentAdapter(getActivity(), student_list);

                            listViewfees.setAdapter(customFeeListStudentAdapter);

                        } catch (JSONException e) {

                            System.out.println("This is not good");

                            e.printStackTrace();

                        }

                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                // Toast.makeText(view.Fee.this, error.toString(), Toast.LENGTH_LONG).show();

            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                return headers;
            }

        };

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        requestQueue.add(stringRequest);

    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        // TODO Auto-generated method stub
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.dashboard, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // handle item selection
        switch (item.getItemId()) {
            case R.id.action_settings:
                // do s.th.
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
</code>```

How can the Linear Layout be Added Dynamically within the ListItem?

答:
Try this,
CustomFeeListStudentAdapter </p>

```<code>    //added code
    viewHolder.receiptLinearLayout.removeAllViews();
    for (int i = 0; i < 1; i++) {

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View convertView = layoutinflater.inflate(R.layout.layout_bil_info, null, false);
        convertView.setId(postion);
        TextView student_profile_Fee_Amount = (TextView) convertView.findViewById(R.id.student_profile_fee_amount);
        TextView student_profile_Fee_Description = (TextView) convertView.findViewById(R.id.student_profile_fee_description);
        student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
        student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());
        viewHolder.receiptLinearLayout.addView(convertView);
    }
</code>```

Body:
I am not able to use List within the list so i jump to add the Dynamic Linear Layout to be Added inside the ListItems.I want to show the list which contains many textview and below the textview i want to display Another listview.So i switch to add Linear Layout dynamically within the parent list.

xml

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/linear_receipt1_fee"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#008b8b"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/student_profile_fee_ReceiptIssuedDate"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="6dp"
                    android:text="Date"
                    android:textColor="#fff"
                    android:textStyle="bold" />

                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#FFFFFF" />

                <TextView
                    android:id="@+id/student_profile_fee_ReceiptIssuedNumber"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:padding="6dp"
                    android:text="Receipt number"
                    android:textColor="#fff"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/receipt1_fee"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#A4ACB0"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center_horizontal"
                        android:padding="5dp"
                        android:text="Description"
                        android:textSize="12dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center_horizontal"
                        android:padding="5dp"
                        android:text="Amount (Nrs) "
                        android:textSize="12dp"
                        android:textStyle="bold">

                    </TextView>

                </LinearLayout>

**how can this linear layout be repeatedly added inside the list items**
                <LinearLayout
                    android:id="@+id/student_profile_fee_linearlayout1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/student_profile_fee_description"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left|center"
                        android:paddingLeft="70dp"
                        android:paddingTop="10dp"
                        android:text="Sports"
                        android:textSize="10dp" />

                    <TextView
                        android:id="@+id/student_profile_fee_amount"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left|center"
                        android:paddingLeft="70dp"
                        android:paddingTop="10dp"
                        android:text="1000"
                        android:textSize="10dp" />
                </LinearLayout>    **end here **
 <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Total"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="552"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Status"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/student_profile_fee_status"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Paid"
                        android:textColor="#108B89"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#C5CED1" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#DCE2E8"
                    android:orientation="horizontal"
                    android:padding="5dp">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="Received Date"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/student_profile_fee_FeeReceiptDate"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:paddingLeft="70dp"
                        android:text="9 March,2017"
                        android:textSize="10dp"
                        android:textStyle="bold" />

                </LinearLayout>
            </LinearLayout>

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#fff" />
   </LinearLayout>

CustomFeeListStudentAdapter

public class CustomFeeListStudentAdapter extends BaseAdapter {
    LinearLayout reciptViewDynamic;

    Context mContext;
    Fee fee = new Fee();

    ArrayList<StudentFeeInformation> student_list;

    LinearLayout linearLayout;

    String TAG = "HomeTab_adapter";

    public CustomFeeListStudentAdapter(Context mContext, ArrayList<StudentFeeInformation> student_list) {
        super();
        this.mContext = mContext;
        this.student_list = student_list;
    }

    @Override
    public int getCount() {

        System.out.println(student_list.size());
        return student_list.size();
    }

    @Override
    public Object getItem(int arg0) {
        return student_list.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(final int postion, View convertView, ViewGroup parent) {
        final Holder viewHolder;

        if (convertView == null) {
            // inflate the layout
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.fragment_fee, parent, false);

            // well set up the ViewHolder
            viewHolder = new Holder();
            viewHolder.student_profile_fee_status = (TextView) convertView.findViewById(R.id.student_profile_fee_status);
            viewHolder.student_profile_ReceiptIssuedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedDate);
            viewHolder.student_profile_ReceiptIssuedNumber = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedNumber);
            viewHolder.student_profile_FeeReceivedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_FeeReceiptDate);
            // viewHolder.student_profile_Fee_Amount = (TextView) convertView.findViewById(R.id.student_profile_fee_amount);
            // viewHolder.student_profile_Fee_Description = (TextView) convertView.findViewById(R.id.student_profile_fee_description);

            //added code
            viewHolder.receiptLinearLayout = (LinearLayout) convertView.findViewById(R.id.recipt_layout);

        } else {
            // we've just avoided calling findViewById() on resource everytime
            // just use the viewHolder
            viewHolder = (Holder) convertView.getTag();
        }

        Log.d(TAG, "@@ postion:" + postion + " getFeeDescription" + student_list.get(postion).getFeeDescription());
        Log.d(TAG, "@@ postion:" + postion + " getAmount" + student_list.get(postion).getAmount());

        viewHolder.student_profile_fee_status.setText(student_list.get(postion).getStatus());
        viewHolder.student_profile_ReceiptIssuedDate.setText(student_list.get(postion).getReceiptIssuedDate());
        viewHolder.student_profile_ReceiptIssuedNumber.setText(student_list.get(postion).getReceiptIssuedNumber());
        viewHolder.student_profile_FeeReceivedDate.setText(student_list.get(postion).getFeeReceivedDate());
        //  viewHolder.student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
        // viewHolder.student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());

        //added code
        for (int i = 0; i < 1; i++) {

            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            //   reciptViewDynamic = (LinearLayout) inflater.inflate(R.layout.layout_bil_info, null);

            reciptViewDynamic = (LinearLayout) inflater.inflate(R.layout.layout_bil_info, parent, false);
            viewHolder.student_profile_Fee_Amount = (TextView) reciptViewDynamic.findViewById(R.id.student_profile_fee_amount);
            viewHolder.student_profile_Fee_Description = (TextView) reciptViewDynamic.findViewById(R.id.student_profile_fee_description);
            viewHolder.student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
            viewHolder.student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());

            viewHolder.receiptLinearLayout.addView(reciptViewDynamic);
            viewHolder.receiptLinearLayout.removeAllViews();

        }

        convertView.setTag(viewHolder);
        return convertView;
    }

    class Holder {
        TextView student_profile_fee_status;
        TextView student_profile_ReceiptIssuedDate;
        TextView student_profile_ReceiptIssuedNumber;
        TextView student_profile_FeeReceivedDate;
        TextView student_profile_Fee_Amount;
        TextView student_profile_Fee_Description;
        LinearLayout receiptLinearLayout;

    }

}

Fee

  public class Fee extends Fragment /*implements View.OnClickListener   */ {

    LinearLayout receipt1, receipt2, receipt3, receipt4;
    LinearLayout receipt1detail, receipt2detail, receipt3detail, receipt4detail;
    LinearLayout DescriptionAmount;

    TextView statustextView, feedescription, feeamount;
    ListView listViewfees, listviewfeedetail;
    List<StudentFeeInformation> yourData = new ArrayList<StudentFeeInformation>();

    public static final String Navigation_URL = "http://192.168.100.5:84/Api/financeApi/getAllFees";
    String Amount;
    String Descriptionlist, status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate;
    ArrayList arrayList = new ArrayList();
    String master_id;

    LinearLayout linearLayout;
    TextView textView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.student_fees_listview, container, false);
        inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // view1 = inflater.inflate(R.layout.student_fees_description_data, null);

        setHasOptionsMenu(true);
        receipt1 = (LinearLayout) view.findViewById(R.id.linear_receipt1_fee);

        //  receipt4 = (LinearLayout) view.findViewById(R.id.linear_receipt4_fee);

        //  receipt1detail = (LinearLayout) view.findViewById(R.id.receipt1_fee);
        //  receipt2detail = (LinearLayout) view.findViewById(R.id.receipt2_fee);
        //  receipt3detail = (LinearLayout) view.findViewById(R.id.receipt3_fee);
        //  receipt4detail = (LinearLayout) view.findViewById(R.id.receipt4_fee);

        //   receipt1.setOnClickListener(this);
        //   receipt2.setOnClickListener(this);
        //   receipt3.setOnClickListener(this);
        //   receipt4.setOnClickListener(this);

        //   receipt1detail.setVisibility(View.VISIBLE);
        //   receipt2detail.setVisibility(View.GONE);
        //   receipt3detail.setVisibility(View.GONE);
        //   receipt4detail.setVisibility(View.GONE);

        statustextView = (TextView) view.findViewById(R.id.student_profile_fee_status);
        SessionManagement sessionManagement = new SessionManagement(getContext());
        master_id = sessionManagement.getMasterId();
        listViewfees = (ListView) view.findViewById(R.id.list_student_fees);
        // listviewfeedetail = (ListView) view.findViewById(R.id.listtest);

        //  DescriptionAmount = (LinearLayout) view.findViewById(R.id.student_profile_fee_linearlayout1);
        // DescriptionAmount.addView(view);

        linearLayout = (LinearLayout) view.findViewById(R.id.student_profile_fee_linearlayout1);
        //   v = (LinearLayout)( view.inflate(getContext(), R.layout.student_fees_description_data, null));
        //  linearLayout.addView(view);

        feedescription = (TextView) view.findViewById(R.id.student_profile_fee_description);
        feeamount = (TextView) view.findViewById(R.id.student_profile_fee_amount);

        textView = (TextView) view.findViewById(R.id.student_profile_fee_amount);

        getUsersListData();

        return view;
    }

    private void getUsersListData() {

        String URL = Navigation_URL + "?id=" + master_id + "&fromDate=" + "&toDate=";
        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {

                            ArrayList<StudentFeeInformation> student_list = new ArrayList<>();
                            ArrayList<ArrayList> student_list_description = new ArrayList<>();

                            JSONArray jArray = new JSONArray(response);

                            //  studentFeeInformation = new StudentFeeInformation(response);
                            for (int i = 0; i < jArray.length(); i++) {
                                JSONObject jsonObject = jArray.getJSONObject(i);

                                status = jsonObject.getString("Status");
                                DateofReceiptIssued = jsonObject.getString("DateOfReciept").substring(0, 10);
                                ReceiptNumber = jsonObject.getString("RecieptNo");
                                FeeReceivedDate = jsonObject.getString("recivedDate").substring(0, 10);

                                String Description = jsonObject.getString("Description");
                                JSONArray jArray1 = new JSONArray(Description);

                                //
                                for (int j = 0; j < jArray1.length(); j++) {

                                    JSONObject jsonObjectinner = jArray1.getJSONObject(j);
                                    Descriptionlist = jsonObjectinner.getString("des");
                                    Amount = jsonObjectinner.getString("Amount");
                                    arrayList.add(Descriptionlist);
                                    Log.d("ArrayList", String.valueOf(arrayList));
                                    student_list.add(new StudentFeeInformation(Descriptionlist, Amount));

                                }
                                student_list.add(new StudentFeeInformation(status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate));

                            }

                            System.out.println("student_list size:" + student_list.size());
                            CustomFeeListStudentAdapter customFeeListStudentAdapter = new CustomFeeListStudentAdapter(getActivity(), student_list);

                            listViewfees.setAdapter(customFeeListStudentAdapter);

                        } catch (JSONException e) {

                            System.out.println("This is not good");

                            e.printStackTrace();

                        }

                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                // Toast.makeText(view.Fee.this, error.toString(), Toast.LENGTH_LONG).show();

            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                return headers;
            }

        };

        RequestQueue requestQueue = Volley.newRequestQueue(getContext());
        requestQueue.add(stringRequest);

    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        // TODO Auto-generated method stub
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.dashboard, menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // handle item selection
        switch (item.getItemId()) {
            case R.id.action_settings:
                // do s.th.
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

How can the Linear Layout be Added Dynamically within the ListItem?

Body:
Try this,
CustomFeeListStudentAdapter

    //added code
    viewHolder.receiptLinearLayout.removeAllViews();
    for (int i = 0; i < 1; i++) {

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View convertView = layoutinflater.inflate(R.layout.layout_bil_info, null, false);
        convertView.setId(postion);
        TextView student_profile_Fee_Amount = (TextView) convertView.findViewById(R.id.student_profile_fee_amount);
        TextView student_profile_Fee_Description = (TextView) convertView.findViewById(R.id.student_profile_fee_description);
        student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
        student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());
        viewHolder.receiptLinearLayout.addView(convertView);
    }


来源: stackexchange

问:
Why does the temporal dead zone exists?
I know what is the temporal dead zone (TDZ), but I can't understand the purpose of it existence.

Can anyone explain me why it was created?

What is the logic of it raising a ReferenceError or a SyntaxError instead of returning undefined?

ReferenceError:

console.log(typeof foo);
let foo;```
</div>
</div>
</p>

<p><strong>SyntaxError:</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let foo;
let foo;</code>```

Undefined:

console.log(typeof foo);```

答:
If you examine the documentation for those exceptions you linked in your question, you can see the why, which I don't think has been addressed here.

A side note first: it bears mentioning that exceptions didn't exist in EMCAScript until edition 3. var obviously predates this language feature by a lot. why var and let are different is largely due to the fact that exceptions were available when let was introduced, and not when var was introduced. That history underlines all of this. 1999 was a busy year, also!

Anyway, into the gears. Look what happens here:

// example A
(function () {
console.log(somethingUndefined - 1);
var somethingUndefined;
console.log('another operation');
})();```
</div>
</div>
</p>

<p>An error, then the code plows on. Can we catch this and deal with it?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// example B
(function () {
try {
    console.log(somethingUndefined - 1);
    var somethingUndefined = 50;
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    return;
}

console.log('plowing on');
})();</code>```

Nope.

Behind the scenes, this code looks like this:

// example C
(function () {
var somethingUndefined = undefined;
try {
    console.log(somethingUndefined - 1);
    somethingUndefined = 50;
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    return;
}

console.log('plowing on');
})();```
</div>
</div>
</p>

<p>There is no "temporal dead zone" because there is no point in example B & C where the variable <code>somethingUndefined</code> is not something. It's a typeof "undefined", <code>somethingUndefined === undefined</code>, that's not nothing. Then it's 50, but too late to be useful. Useful or not, we can use it to do things because it has a value. Line 1, line 8, it always has <em>some</em> value. Compare the difference in output here:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>// example D
(function () {
try {
    console.log(somethingUndeclared - 1);
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    console.log(e);
}
})();</code>```

At every point in example D, somethingUndeclared is nothing. It's an always dead zone. I am not sure which EMCAScript edition the above code began to throw exceptions, but it's less breaking for it to do so because this situation is always going to be an error.

Unless in some other part of the same scope OR the parent scopes somethingUndeclared was defined, probably for some other purpose. Or maybe the code var somethingUndeclared; is laying around somewhere in the scope or the parent scopes for some reason, so there's no exception thrown in anoy of the code above. That's the argument for using let or const almost exclusively.

When you use let or const, there is a "dead zone," a point in time when it isn't anything, then it will be something. It isn't undefined, it's an exception waiting to happen. Until the let statement is reached, it acts like an undeclared variable, throwing an exception, then at the declaration line it acts like a var with a value. It is a blending of the behavior of var with the outcome of an undeclared variable.

// example D
(function () { // temporal dead zone, something is nothing
try { // temporal dead zone, something is nothing
    console.log(something - 1); // exceptional behavior! temporal dead zone
    let something  = 50; // temporal live zone begins here!
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here'); // you could call this a dead zone
    console.log(e); // dead
}
// dead
})(); // way dead```

Which moves us on to the begged question, "why not pull off the bandaid, deal with the BC break for the sake of consistency in the language?" The answer to that is because good enough is usually good enough. There are millions of lines of javascript managing accordions and image galleries and other UI bells and whistles. One opts-in to a more mature set of language features when EMCAScript is filling mission-critical roles. Or you just don't like sloppy code for your sweet tab navigation. Consistency in the language is not worth breaking all of the code out there that is good enough to do what it needs to do most of the time. Imagine the mountains of good enough that have accumulated since it was even possible to throw an exception in this language ('99).

When we need it to do what it is supposed to do all of the time, we can harness these features. When it would be a catastrophe for undefined = 100; to be in some file in the project, we can opt-in to exceptions. When the progressive enhancement fails and we get no tooltips, we have a less-nice UX than we'd hoped for. var and let have different histories and different weight on their shoulders, so they're likely to always act differently.

ContentLicense: CC BY-SA 3.0

Title: Why does the temporal dead zone exists?

Body:
I know what is the temporal dead zone (TDZ), but I can't understand the purpose of it existence.

Can anyone explain me why it was created?

What is the logic of it raising a ReferenceError or a SyntaxError instead of returning undefined?

ReferenceError:

console.log(typeof foo);
let foo;

SyntaxError:

let foo;
let foo;

Undefined:

console.log(typeof foo);

Body:
If you examine the documentation for those exceptions you linked in your question, you can see the why, which I don't think has been addressed here.

A side note first: it bears mentioning that exceptions didn't exist in EMCAScript until edition 3. var obviously predates this language feature by a lot. why var and let are different is largely due to the fact that exceptions were available when let was introduced, and not when var was introduced. That history underlines all of this. 1999 was a busy year, also!

Anyway, into the gears. Look what happens here:

// example A
(function () {
console.log(somethingUndefined - 1);
var somethingUndefined;
console.log('another operation');
})();

An error, then the code plows on. Can we catch this and deal with it?

// example B
(function () {
try {
    console.log(somethingUndefined - 1);
    var somethingUndefined = 50;
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    return;
}

console.log('plowing on');
})();

Nope.

Behind the scenes, this code looks like this:

// example C
(function () {
var somethingUndefined = undefined;
try {
    console.log(somethingUndefined - 1);
    somethingUndefined = 50;
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    return;
}

console.log('plowing on');
})();

There is no "temporal dead zone" because there is no point in example B & C where the variable somethingUndefined is not something. It's a typeof "undefined", somethingUndefined === undefined, that's not nothing. Then it's 50, but too late to be useful. Useful or not, we can use it to do things because it has a value. Line 1, line 8, it always has some value. Compare the difference in output here:

// example D
(function () {
try {
    console.log(somethingUndeclared - 1);
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here');
    console.log(e);
}
})();

At every point in example D, somethingUndeclared is nothing. It's an always dead zone. I am not sure which EMCAScript edition the above code began to throw exceptions, but it's less breaking for it to do so because this situation is always going to be an error.

Unless in some other part of the same scope OR the parent scopes somethingUndeclared was defined, probably for some other purpose. Or maybe the code var somethingUndeclared; is laying around somewhere in the scope or the parent scopes for some reason, so there's no exception thrown in anoy of the code above. That's the argument for using let or const almost exclusively.

When you use let or const, there is a "dead zone," a point in time when it isn't anything, then it will be something. It isn't undefined, it's an exception waiting to happen. Until the let statement is reached, it acts like an undeclared variable, throwing an exception, then at the declaration line it acts like a var with a value. It is a blending of the behavior of var with the outcome of an undeclared variable.

// example D
(function () { // temporal dead zone, something is nothing
try { // temporal dead zone, something is nothing
    console.log(something - 1); // exceptional behavior! temporal dead zone
    let something  = 50; // temporal live zone begins here!
    console.log('another operation');
} catch (e) {
    console.log('I want to deal with problems here'); // you could call this a dead zone
    console.log(e); // dead
}
// dead
})(); // way dead

Which moves us on to the begged question, "why not pull off the bandaid, deal with the BC break for the sake of consistency in the language?" The answer to that is because good enough is usually good enough. There are millions of lines of javascript managing accordions and image galleries and other UI bells and whistles. One opts-in to a more mature set of language features when EMCAScript is filling mission-critical roles. Or you just don't like sloppy code for your sweet tab navigation. Consistency in the language is not worth breaking all of the code out there that is good enough to do what it needs to do most of the time. Imagine the mountains of good enough that have accumulated since it was even possible to throw an exception in this language ('99).

When we need it to do what it is supposed to do all of the time, we can harness these features. When it would be a catastrophe for undefined = 100; to be in some file in the project, we can opt-in to exceptions. When the progressive enhancement fails and we get no tooltips, we have a less-nice UX than we'd hoped for. var and let have different histories and different weight on their shoulders, so they're likely to always act differently.


问:
Laravel pass variable from controller query to model function
I have a function on my model that check active status in equipment_station table,

originally it only checked one status, now i need to pass a parameter to the model with active or inactive values, I've tried this with no success.

controller:

model :

How can i change the parameter in the model, I send status from controller as inactive or active.

thanks in advance

答:
You could Constraint Eager Loading by specifying additional query constraints for the eager loading

```<code>$historial_estaction =
Estacion::where('estacion.id', $id)
   ->whereHas('equipos', function($query) use ($estado1) {
        $query->where('equipo_estacion.estado', $estado1);
    })->with(['equipos' => function ($query) use ($estado1) {
        $query->where('estado', $estado1);
    }])->get();
</code>```

Model:

```<code>public function equipos()
{
    return $this->belongsToMany('App\Equipo')
                ->withPivot('estado')
                ->withTimestamps();
}
</code>```

Body:
You could Constraint Eager Loading by specifying additional query constraints for the eager loading

$historial_estaction =
Estacion::where('estacion.id', $id)
   ->whereHas('equipos', function($query) use ($estado1) {
        $query->where('equipo_estacion.estado', $estado1);
    })->with(['equipos' => function ($query) use ($estado1) {
        $query->where('estado', $estado1);
    }])->get();

Model:

public function equipos()
{
    return $this->belongsToMany('App\Equipo')
                ->withPivot('estado')
                ->withTimestamps();
}


问:
How to create a simple pagination/carousel in divs HTML Angular 2
Hi I have an *ngFor in my template and it creates n number of divs.

```<code><div *ngFor="let item of widgets" class="page-content widget-item">
  <div>{{content}} </div>
</div>
</code>```

How can I add a simple pagination on my div's guys? So that my first page will have 10 divs and on click on a button, the page slides and shows the rest of the divs? Any idea? Thanks in advance.

答:
This link may benefits your need

http://jasonwatmore.com/post/2016/08/23/angular-2-pagination-example-with-logic-like-google

Body:
Hi I have an *ngFor in my template and it creates n number of divs.

{{content}}

How can I add a simple pagination on my div's guys? So that my first page will have 10 divs and on click on a button, the page slides and shows the rest of the divs? Any idea? Thanks in advance.


问:
Issues with Save-AzureRmProfile
I have created virtual machine in Azure and selected Windows Server 2012 R2.

I have installed windows PowerShell using the Web platform installer. When I try to run the following command:

```<code>Save-AzureRmProfile -Path C:\MyPath\myfile.json
</code>```

It throws the error:

The term 'Save-AzureRmProfile' is not recognized as the name of a
  cmdlet, function, script file, or operable program. Check the
  spelling of the name, or if a path was included, verify that the path
  is correct and try again.

I have tried to follow this link here by adding environments variables but no help. Has anyone solved this issue?

答:
Save-AzureRmContext and Import-AzureRmContext can be used for same purpose on Version 4.0
Usage is same!</p>

Title: Issues with Save-AzureRmProfile

Body:
I have created virtual machine in Azure and selected Windows Server 2012 R2.

I have installed windows PowerShell using the Web platform installer. When I try to run the following command:

Save-AzureRmProfile -Path C:\MyPath\myfile.json

It throws the error:

The term 'Save-AzureRmProfile' is not recognized as the name of a
  cmdlet, function, script file, or operable program. Check the
  spelling of the name, or if a path was included, verify that the path
  is correct and try again.

I have tried to follow this link here by adding environments variables but no help. Has anyone solved this issue?


问:
How to modify variables of another scope?
Currectly, I'm trying the following: Some mutator function accepts other function's local scope using locals()

```<code>def mutator(locals):
    locals['n'] = 10
    locals['l'].append(10)

def f():
    n = 1
    l = [1]
    mutator(locals())
    print(n,l) # >>> 1, [1,10]

f(None)
</code>```

and that works as expected: I was able to modify mutable list contents but failed to 'rebind' another immutable int to the same name.

Currently, I see some options:

eval(), exec() & Co

Play with stack frames & local variables in mutator()

Keep such variables in a dict: not very handy but probably the best one

The restriction is: target function f() can contain just one function call, possibly with arguments, and that function should be able to alter values in f()s current scope.

So.. is there a way to reintroduce variable's value (bind another object) at runtime? I don't believe there is no good trick to achive this!

Here's an example of the thing I'm trying to achieve:

```<code>def view(request): # Yes, that's Django!
    q = MyModel.objects.all()

    data = { 'some_action': True, 'items_per_page': 50 } # defaults. Mutators can change this
    mutators.launch(locals(), data ) # Launch mutators that may want to narrow the QuerySet

    if data['some_action']: # do something useful if no mutator has disabled it
          ...

    # paginate using data['items_per_page']
</code>```

I don't want to use data dict here: ability to modify them as local variables would be much better & pretty. Note that q QuerySet object is mutable & mutators can alter its contents.

答:
Do it this way:

```<code>def mutator(l):
    l.append(10)
    return 10

def f():
    n = 1
    l = [1]
    n = mutator(l)
    print(n,l) # >>> 1, [1,10]

f()
</code>```

Yeah, I know it isn't the clever hack you want; but it works. :-)

If you want a set of global configuration options that you can turn on and tune, stick all of them on an object:

```<code>class Settings(object):
    def __init__(self):
         self.n = 1
         self.l = [1]
</code>```

Now you can change the variables to your hearts content.

ContentLicense: CC BY-SA 2.5

Body:
Currectly, I'm trying the following: Some mutator function accepts other function's local scope using locals()

def mutator(locals):
    locals['n'] = 10
    locals['l'].append(10)

def f():
    n = 1
    l = [1]
    mutator(locals())
    print(n,l) # >>> 1, [1,10]

f(None)

and that works as expected: I was able to modify mutable list contents but failed to 'rebind' another immutable int to the same name.

Currently, I see some options:

eval(), exec() & Co

Play with stack frames & local variables in mutator()

Keep such variables in a dict: not very handy but probably the best one

The restriction is: target function f() can contain just one function call, possibly with arguments, and that function should be able to alter values in f()s current scope.

So.. is there a way to reintroduce variable's value (bind another object) at runtime? I don't believe there is no good trick to achive this!

Here's an example of the thing I'm trying to achieve:

def view(request): # Yes, that's Django!
    q = MyModel.objects.all()

    data = { 'some_action': True, 'items_per_page': 50 } # defaults. Mutators can change this
    mutators.launch(locals(), data ) # Launch mutators that may want to narrow the QuerySet

    if data['some_action']: # do something useful if no mutator has disabled it
          ...

    # paginate using data['items_per_page']

I don't want to use data dict here: ability to modify them as local variables would be much better & pretty. Note that q QuerySet object is mutable & mutators can alter its contents.

Body:
Do it this way:

def mutator(l):
    l.append(10)
    return 10

def f():
    n = 1
    l = [1]
    n = mutator(l)
    print(n,l) # >>> 1, [1,10]

f()

Yeah, I know it isn't the clever hack you want; but it works. :-)

If you want a set of global configuration options that you can turn on and tune, stick all of them on an object:

class Settings(object):
    def __init__(self):
         self.n = 1
         self.l = [1]

Now you can change the variables to your hearts content.


问:
typescript, Argument of type 'xxx' is not assignable to parameter of type 'string'
typescript give me this hint when I write a new Error({code: 404, msg: 'user is not existed'}) statement.

[ts] Argument of type '{ code: number; msg: string; }' is not assignable to parameter of type 'string'.

How can I solve this? Here is my code snippet:

```<code>const fetchData_V2 = (num: number): Promise<User> => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if(num > 0) {
        const user: User = new User('novaline', 26);
        resolve(user);
      } else {
        reject(new Error({code: 404, msg: 'user not exist'}));
      }

    }, 1000);
  });
}
</code>```

答:
Check out the definition for the Error constructor:

```<code>interface ErrorConstructor {
    new (message?: string): Error;
    (message?: string): Error;
    readonly prototype: Error;
}
</code>```

Check out the documentation:

new Error([message[, fileName[, lineNumber]]])

          message Optional. Human-readable description of the error.

Body:
typescript give me this hint when I write a new Error({code: 404, msg: 'user is not existed'}) statement.

[ts] Argument of type '{ code: number; msg: string; }' is not assignable to parameter of type 'string'.

How can I solve this? Here is my code snippet:

const fetchData_V2 = (num: number): Promise<User> => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if(num > 0) {
        const user: User = new User('novaline', 26);
        resolve(user);
      } else {
        reject(new Error({code: 404, msg: 'user not exist'}));
      }

    }, 1000);
  });
}

Body:
Check out the definition for the Error constructor:

interface ErrorConstructor {
    new (message?: string): Error;
    (message?: string): Error;
    readonly prototype: Error;
}

Check out the documentation:

new Error([message[, fileName[, lineNumber]]])

          message Optional. Human-readable description of the error.


问:
Replace get parameters in Codeigniter pagination?
The following piece of code for my pagination function like following:-

```<code>public function news()
    {
        $this->load->library('pagination');
        $config = array();

        $config["base_url"] = base_url() . "index.php/welcome/news";
        $this->load->model('news_model');
        $total_row = $this->news_model->record_count();
        $config["total_rows"] = $total_row;
        $config["per_page"] = 1;
        $config['use_page_numbers'] = TRUE;
        $config['num_links'] = $total_row;
        $config['cur_tag_open'] = ' <a class="current">';
        $config['cur_tag_close'] = '</a>';

        $config['page_query_string'] = TRUE;
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Previous';
        $config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
        $this->pagination->initialize($config);
        if($this->uri->segment(3)){
        $page = ($this->uri->segment(3)) ;
        }
        else{
        $page = 1;
        } //echo $config["per_page"].'/'.$page; exit();
        $this->load->model('news_model');
        $data["results"] = $this->news_model->fetch_data($config["per_page"], $page);
        $str_links = $this->pagination->create_links();
        $data["links"] = explode(' ',$str_links );

        $this->load->model('news_model');
        $data['lt_news'] = $this->news_model->get_lt_newsletter();
        $data['rm_news'] = $this->news_model->get_rm_newsletter();
        $this->load->view('newsletter/newsletter',$data);
    }
</code>```

From the above code, the url browser shows like the following:-

```<code>http://localhost/ins/index.php/welcome/news?per_page=2
</code>```

I am like jammed as to how to change it to be look like the following:

```<code>http://localhost/ins/index.php/welcome/news/2
</code>```

Is there a way to do it..?  I am newbie to the pagination in codeigniter so, i do not know if there is a necessity to change the url parameters to be looking like the above..?

答:
Make the page a parameter of the function, like so:

```<code>public function news($pageNum)
    {
        ...
        $page = $pageNum
        ...
    }
</code>```

Then you should be able to access it via:

```<code>http://localhost/ins/index.php/welcome/news/2
</code>```

ContentLicense: CC BY-SA 4.0

Body:
The following piece of code for my pagination function like following:-

public function news()
    {
        $this->load->library('pagination');
        $config = array();

        $config["base_url"] = base_url() . "index.php/welcome/news";
        $this->load->model('news_model');
        $total_row = $this->news_model->record_count();
        $config["total_rows"] = $total_row;
        $config["per_page"] = 1;
        $config['use_page_numbers'] = TRUE;
        $config['num_links'] = $total_row;
        $config['cur_tag_open'] = ' ';
        $config['cur_tag_close'] = '';

        $config['page_query_string'] = TRUE;
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Previous';
        $config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);
        $this->pagination->initialize($config);
        if($this->uri->segment(3)){
        $page = ($this->uri->segment(3)) ;
        }
        else{
        $page = 1;
        } //echo $config["per_page"].'/'.$page; exit();
        $this->load->model('news_model');
        $data["results"] = $this->news_model->fetch_data($config["per_page"], $page);
        $str_links = $this->pagination->create_links();
        $data["links"] = explode(' ',$str_links );

        $this->load->model('news_model');
        $data['lt_news'] = $this->news_model->get_lt_newsletter();
        $data['rm_news'] = $this->news_model->get_rm_newsletter();
        $this->load->view('newsletter/newsletter',$data);
    }

From the above code, the url browser shows like the following:-

http://localhost/ins/index.php/welcome/news?per_page=2

I am like jammed as to how to change it to be look like the following:

http://localhost/ins/index.php/welcome/news/2

Is there a way to do it..?  I am newbie to the pagination in codeigniter so, i do not know if there is a necessity to change the url parameters to be looking like the above..?

Body:
Make the page a parameter of the function, like so:

public function news($pageNum)
    {
        ...
        $page = $pageNum
        ...
    }

Then you should be able to access it via:

http://localhost/ins/index.php/welcome/news/2


问:
Concatenate two values or variables in AngularJS?
I am new with angularJS. and trying to concatenate two variables?

```<code>ng-init = "imgid={{$parent.$index+$index}}"
</code>```

also tried=>

```<code>setImgCounter(post.postImages.length,$parent.$index+$index)
</code>```

here $index=3 and $oarent.$index=3. I want something like 33 but it is showing me 6 . setImgCounter is a function and I want to send $parent.$index+$index as a variable.is there any way to achieve 33 instate of 6.

答:
Try doing something like</p>

```<code>ng-init = "imgid={{$parent.$index}}{{$index}}"
</code>```

Body:
I am new with angularJS. and trying to concatenate two variables?

ng-init = "imgid={{$parent.$index+$index}}"

also tried=>

setImgCounter(post.postImages.length,$parent.$index+$index)

here $index=3 and $oarent.$index=3. I want something like 33 but it is showing me 6 . setImgCounter is a function and I want to send $parent.$index+$index as a variable.is there any way to achieve 33 instate of 6.

Body:
Try doing something like

ng-init = "imgid={{$parent.$index}}{{$index}}"


问:
R: Replace Special Characters
I have a dataframe as with special characters as below

```<code>Key  Q1   Q2
22   aSk   aÃ…Â k
23   aSk   aÃ…Â k
24   aSk   aÃ…Â k
</code>```

I would like to replace the "Ã…Â k" (including the space between k) in Q2 with "aSk" to have result as below (same as Q1)

```<code>Key  Q1   Q2
22   aSk   aSk
23   aSk   aSk
24   aSk   aSk
</code>```

I have tried to use gsub function in R

```<code>df$Q2 <- gsub("[Ã…Â]", "S", df$Q2)
</code>```

but I'm unable to remove the "space" and get the result as below instead

```<code>Key  Q1   Q2
22   aSk   aSSS k
23   aSk   aSSS k
24   aSk   aSSS k
</code>```

Can I know what's wrong with my code and how to remove the "space" and "SSS" in R?

(The actual word in my raw file in csv is "aÅ k". However, it appears as "aÃ…Â k" in R)

Thanks.

答:
We can match one or more characters that are not alpbabets and replace it with "S"

```<code>df$Q2 <- sub("[^A-Za-z]+", "S", df$Q2)
df$Q2
#[1] "aSk" "aSk" "aSk"
</code>```

Or we capture only the alphabetic characters as a group (([A-Za-z]*) from the start (*) of the string, match the following characters that are non-alphabets and replace with the backreference of the captured group followed by "S"

```<code>sub("^([A-Za-z]*)[^A-Za-z]+", "\\1S", df$Q2)
#[1] "aSk" "aSk" "aSk"
</code>```

Title: R: Replace Special Characters

Body:
I have a dataframe as with special characters as below

Key  Q1   Q2
22   aSk   aÃ…Â k
23   aSk   aÃ…Â k
24   aSk   aÃ…Â k

I would like to replace the "Ã…Â k" (including the space between k) in Q2 with "aSk" to have result as below (same as Q1)

Key  Q1   Q2
22   aSk   aSk
23   aSk   aSk
24   aSk   aSk

I have tried to use gsub function in R

df$Q2 <- gsub("[Ã…Â]", "S", df$Q2)

but I'm unable to remove the "space" and get the result as below instead

Key  Q1   Q2
22   aSk   aSSS k
23   aSk   aSSS k
24   aSk   aSSS k

Can I know what's wrong with my code and how to remove the "space" and "SSS" in R?

(The actual word in my raw file in csv is "aÅ k". However, it appears as "aÃ…Â k" in R)

Thanks.

Body:
We can match one or more characters that are not alpbabets and replace it with "S"

df$Q2 <- sub("[^A-Za-z]+", "S", df$Q2)
df$Q2
#[1] "aSk" "aSk" "aSk"

Or we capture only the alphabetic characters as a group (([A-Za-z]*) from the start (*) of the string, match the following characters that are non-alphabets and replace with the backreference of the captured group followed by "S"

sub("^([A-Za-z]*)[^A-Za-z]+", "\\1S", df$Q2)
#[1] "aSk" "aSk" "aSk"


问:
UWP Background Task - ExecutionTimeExceeded
I have recently ported my LOB Win 8 RT App across to UWP. I am using Background Tasks to connect to web services and download/upload data.

On a low spec Win 10 tablet I have both the Win8 app and UWP app. The Win8 app behaves fine however the UWP app the cancellation event handler gets called with error ExcecutionTimeExceeded.
This occurs after aprox 23 seconds. It does not download all the data (whereas the Win 8 app on same device does).

However when I ran the app on my laptop (higher spec) the background task runs successfully after aprox 40-50 seconds.

Is the "ExectionTimeExceeded" related to the CPU of the device?
Has this changed between Win 8 Store Apps and UWP?

Also - I am using a BackgroundTaskDeferral.

答:
Is the "ExectionTimeExceeded" related to the CPU of the device?

According to BackgroundTaskCancellationReason enum, for ExecutionTimeExceeded it says:

The background task was cancelled because it exceeded its allotted time to run.

In UWP, the background task do has CPU constraint that CPU need guarantee 10% . More constraints you may reference the slide 22 of this PPT. But for the ExecutionTimeExceeded cancel reason it should be caused by constraint of "wall clock quota". Background tasks are limited to 30 seconds of wall-clock usage except for longing trigger (25s for running and 5s for canceling). So your background task should execute less than 25s, if exceeded, task will be canceled and return the ExecutionTimeExceeded cancel reason.

Has this changed between Win 8 Store Apps and UWP?

It may be yes. It seems like in windows 8.1, all background tasks have CPU and network usage quotas but there're no wall clock quota limits. More details please reference slide 21 of this PPT.

However when I ran the app on my laptop (higher spec) the background task runs successfully after aprox 40-50 seconds.

For this I'm not sure why this happened on your side. Maybe your laptop is windows 8.1, or you calculate the wrong execute time, or some other reasons. But the background task just limited to 30 seconds as I mentioned above no matter how higher spec of your device.

More details please reference Support your app with background tasks.


答:
You need to convert your integers to string to concatenate, then the resulting string back to integer for later process (I imagine):</p>

```<code>parseInt($parent.$index+""+$index)
</code>```

Title: Concatenate two values or variables in AngularJS?

Body:
You need to convert your integers to string to concatenate, then the resulting string back to integer for later process (I imagine):

parseInt($parent.$index+""+$index)


问:
Why I couldn't sign in Android Studio for firebase?
Am trying to log in the  Android Studio for firebase creation but I couldn't sign in it's showing the popup message please sign via the opened browser and loading as long as still.

Anyone, Please solve my problem.
Thanks in Advance.

答:
You can try to connect with Firebase Assistant.  If it doesn't work check your proxy settings and make sure you disabled all proxy for a while.

after that allow your google account to log in with Studio and you done. If you have any doubts comment below


问:
how to call method in login page
i'm currently trying to make a validation for a login page, which is to validate whether the account is in my database or not, i'm to call the method of invokelogin(), but it seems  but i don't know how to call the method, need some help with it.</p>

```<code>import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

public class Activity_Login extends Activity{

   private Button btnSignIn;

   String username;
   String pass;

   public static final String USER_NAME = "USERNAME";

   EditText txtUser;
   EditText Pass;

   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    btnSignIn = (Button) findViewById(R.id.btnSignIn);
    btnSignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchActivity3();
        }
    });
}

public void launchActivity3() {

    txtUser = (EditText) findViewById(R.id.txtUser);
    Pass = (EditText) findViewById(R.id.txtPass);

    if (txtUser.getText().toString().equals("")) {
        Toast.makeText(Activity_Login.this, "UserName must Be Filled", Toast.LENGTH_SHORT).show();
    } else if (Pass.getText().toString().equals("")) {
        Toast.makeText(Activity_Login.this, "Password must be Filled", Toast.LENGTH_SHORT).show();
    } else {
        invokeLogin();
    }
        Intent intent_SignIn = new Intent(Activity_Login.this, Activity_Drawer2.class);
        startActivity(intent_SignIn);
}

public void invokeLogin(View view){
    username = txtUser.getText().toString();
    pass = Pass.getText().toString();

    login(username,pass);
}

private void login (final String username, String pass){

    class LoginAsync extends AsyncTask<String, Void, String> {

        private Dialog loadingDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            loadingDialog = ProgressDialog.show(Activity_Login.this, "Please wait", "Loading...");
        }

        @Override
        protected String doInBackground(String... params) {
            String uname = params[0];
            String pass = params[1];

            InputStream is = null;
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("username", uname));
            nameValuePairs.add(new BasicNameValuePair("password", pass));
            String result = null;

            try {
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost("http://10.10.1.11/login.php");
                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpClient.execute(httpPost);

                HttpEntity entity = response.getEntity();

                is = entity.getContent();

                BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
                StringBuilder sb = new StringBuilder();

                String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
                }
                result = sb.toString();
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return result;
        }

        @Override
        protected void onPostExecute(String result) {
            String s = result.trim();
            loadingDialog.dismiss();
            if (s.equalsIgnoreCase("success")) {
                Intent intent = new Intent(Activity_Login.this, Activity_Drawer2.class);
                intent.putExtra(USER_NAME, username);
                finish();
                startActivity(intent);
            } else {
                Toast.makeText(getApplicationContext(), "Invalid User Name or Password", Toast.LENGTH_LONG).show();
            }
        }
    }

    LoginAsync la = new LoginAsync();
    la.execute(username, pass);
}
}
</code>```

答:
You can pass txtUser and Pass  to  invokeLogin();

so it look like invokeLogin(txtUser,Pass);

Then your invokeLogin method

```<code>public void invokeLogin(String username, String pass){
    login(username,pass);
}
</code>```

Title: how to call method in login page

Body:
i'm currently trying to make a validation for a login page, which is to validate whether the account is in my database or not, i'm to call the method of invokelogin(), but it seems  but i don't know how to call the method, need some help with it.

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

public class Activity_Login extends Activity{

   private Button btnSignIn;

   String username;
   String pass;

   public static final String USER_NAME = "USERNAME";

   EditText txtUser;
   EditText Pass;

   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    btnSignIn = (Button) findViewById(R.id.btnSignIn);
    btnSignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchActivity3();
        }
    });
}

public void launchActivity3() {

    txtUser = (EditText) findViewById(R.id.txtUser);
    Pass = (EditText) findViewById(R.id.txtPass);

    if (txtUser.getText().toString().equals("")) {
        Toast.makeText(Activity_Login.this, "UserName must Be Filled", Toast.LENGTH_SHORT).show();
    } else if (Pass.getText().toString().equals("")) {
        Toast.makeText(Activity_Login.this, "Password must be Filled", Toast.LENGTH_SHORT).show();
    } else {
        invokeLogin();
    }
        Intent intent_SignIn = new Intent(Activity_Login.this, Activity_Drawer2.class);
        startActivity(intent_SignIn);
}

public void invokeLogin(View view){
    username = txtUser.getText().toString();
    pass = Pass.getText().toString();

    login(username,pass);
}

private void login (final String username, String pass){

    class LoginAsync extends AsyncTask<String, Void, String> {

        private Dialog loadingDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            loadingDialog = ProgressDialog.show(Activity_Login.this, "Please wait", "Loading...");
        }

        @Override
        protected String doInBackground(String... params) {
            String uname = params[0];
            String pass = params[1];

            InputStream is = null;
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("username", uname));
            nameValuePairs.add(new BasicNameValuePair("password", pass));
            String result = null;

            try {
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost("http://10.10.1.11/login.php");
                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpClient.execute(httpPost);

                HttpEntity entity = response.getEntity();

                is = entity.getContent();

                BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
                StringBuilder sb = new StringBuilder();

                String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
                }
                result = sb.toString();
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return result;
        }

        @Override
        protected void onPostExecute(String result) {
            String s = result.trim();
            loadingDialog.dismiss();
            if (s.equalsIgnoreCase("success")) {
                Intent intent = new Intent(Activity_Login.this, Activity_Drawer2.class);
                intent.putExtra(USER_NAME, username);
                finish();
                startActivity(intent);
            } else {
                Toast.makeText(getApplicationContext(), "Invalid User Name or Password", Toast.LENGTH_LONG).show();
            }
        }
    }

    LoginAsync la = new LoginAsync();
    la.execute(username, pass);
}
}

Body:
You can pass txtUser and Pass  to  invokeLogin();

so it look like invokeLogin(txtUser,Pass);

Then your invokeLogin method

public void invokeLogin(String username, String pass){
    login(username,pass);
}


问:
Nuget Package Manager Using Static Path for Package Resolution
Each time I install a new package via Nuget's extension in VS, it is checking for the existence of the target package in a static location (C:\Users[me]\Documents\Code\Nuget)

This is an issue when I generate projects, as I cannot check them directly into TFS without editing the .csproj file to resolve dependencies relatively. Those settings are on a package-by-package basis, so it is tedious.

I do not see a difference between my coworker's Nuget/VS2015 install and my own, however, when they add new packages via. Nuget, their manager adds a 'Packages' folder in the project directory. Their project then has relative pathing for Nuget resolution.

What causes this behavior, and what can I do to resolve it?
Since neither of us knowingly updated our Nuget settings, what can cause configuration side-effects like this?

答:
What causes this behavior, and what can I do to resolve it? Since neither of us knowingly updated our Nuget settings, what can cause configuration side-effects like this?

You may set the repositoryPath in your NuGet.config, you can check below settings in the global config file located in %APPDATA%\NuGet\NuGet.Config:

```<code>     <config>
        <add key="repositoryPath" value="C:\Users\Documents\Code\Nuget" />
     </config>
</code>```

If you find it, please comment it or you can delete.

Besides, if you are not find it in the global config, you can check this NuGet.config under your solution.

Note: please restart your Visual Studio after modifying the NuGet.config.

Update:

You can add a NuGet.config under the solution folder with below setting:

```<code><?xml version="1.0" encoding="utf-8"?>
<configuration>
   <config>
      <add key="repositoryPath" value="Packages" />
   </config>
</configuration>
</code>```

With this setting, NuGet will store the packages under the solution folder.

Body:
What causes this behavior, and what can I do to resolve it? Since neither of us knowingly updated our Nuget settings, what can cause configuration side-effects like this?

You may set the repositoryPath in your NuGet.config, you can check below settings in the global config file located in %APPDATA%\NuGet\NuGet.Config:

     <config>
        <add key="repositoryPath" value="C:\Users\Documents\Code\Nuget" />
     </config>

If you find it, please comment it or you can delete.

Besides, if you are not find it in the global config, you can check this NuGet.config under your solution.

Note: please restart your Visual Studio after modifying the NuGet.config.

Update:

You can add a NuGet.config under the solution folder with below setting:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <config>
      <add key="repositoryPath" value="Packages" />
   </config>
</configuration>

With this setting, NuGet will store the packages under the solution folder.


问:
Perl installation issue using Docker
I am trying to build the docker image with perl installation.

Dockerfile:

```<code>FROM amazonlinux
WORKDIR /shared
RUN yum -y install gcc
ADD http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz /shared
RUN tar -xzf perl-5.22.1.tar.gz

WORKDIR /shared/perl-5.22.1
RUN ./Configure -des -Dprefix=/opt/perl-5.22.1/localperl

RUN make
RUN make test
RUN make install
</code>```

all these steps are executed i am can see it executing the make, make test and make install commands but when i do :

```<code>docker run -it testsh /bin/bash
</code>```

Error:

when I  check perl -v it says command not found.

and I need to go the perl directory
'cd perl-5.22.1' and run 'make install' again then perl -v works

But I want the perl installation to work when I build it with docker image. can anyone tell me what is going wrong here?

答:
perl was indeed installed, just wasn't added to the path.
export PATH=$PATH:/shared/perl-5.22.1 should do it -- but of course, you'd want to add a PATH update in the Dockerfile.</p>

Title: Perl installation issue using Docker

Body:
I am trying to build the docker image with perl installation.

Dockerfile:

FROM amazonlinux
WORKDIR /shared
RUN yum -y install gcc
ADD http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz /shared
RUN tar -xzf perl-5.22.1.tar.gz

WORKDIR /shared/perl-5.22.1
RUN ./Configure -des -Dprefix=/opt/perl-5.22.1/localperl

RUN make
RUN make test
RUN make install

all these steps are executed i am can see it executing the make, make test and make install commands but when i do :

docker run -it testsh /bin/bash

Error:

when I  check perl -v it says command not found.

and I need to go the perl directory
'cd perl-5.22.1' and run 'make install' again then perl -v works

But I want the perl installation to work when I build it with docker image. can anyone tell me what is going wrong here?


问:
RegExpression to replace text within tags
I have HTML code as String variable in Coldfusion.

For example:

```<code><cfset str = "<span class='xyz'> sample text within span </span>" >
</code>```

Now I want to repalce the word span from text "sample text within span" but not the tag name.

Can someone help me?

Thanks in advance.

答:
I'm going to dumbly answer your question:

```<code><cfset str = "<span class='xyz'> sample text within span </span>" >

<cfdump var="#str#" />

<!--- Convert to list based on start and end tag brackets --->
<cfset arr = listToArray(str, ">,<") />
<!--- Replace the ACTUAL text --->
<cfset newStr = replace(str, arr[2], "my new text") />

<cfdump var="#newStr#" />
</code>```

Disclaimer: if I caught myself writing this I would probably think myself on the wrong track.

This road leads to one trying to use regular expressions to parse HTML, regarded as a bad thing as mentioned in this article.

Perhaps you can explain your problem a little more and we can help.

Body:
I have HTML code as String variable in Coldfusion.

For example:

<cfset str = " sample text within span " >

Now I want to repalce the word span from text "sample text within span" but not the tag name.

Can someone help me?

Thanks in advance.

Body:
I'm going to dumbly answer your question:

<cfset str = "<span class='xyz'> sample text within span </span>" >

<cfdump var="#str#" />

<!--- Convert to list based on start and end tag brackets --->
<cfset arr = listToArray(str, ">,<") />
<!--- Replace the ACTUAL text --->
<cfset newStr = replace(str, arr[2], "my new text") />

<cfdump var="#newStr#" />

Disclaimer: if I caught myself writing this I would probably think myself on the wrong track.

This road leads to one trying to use regular expressions to parse HTML, regarded as a bad thing as mentioned in this article.

Perhaps you can explain your problem a little more and we can help.


问:
Open google calendar with auto login
Open google calendar with auto login

Requiremment: We want to facility to open a the google calendar with gmail id and pwd without the intervention of the user.So basically it will log out any other user if logged in to google and auto login with provided email and pwd and show the google calendar.

I have already tried following things,

1) Google calendar embed script:   It does not log the user to the
    google if already not logged in and uses which ever the logged in
    users google calendar.

2) Google calendar API:    The google service
    API allows auto authenticate to specific google service account and
    then we can fetch the events but this authentication does not
    actually logs the user to google a/c so we cannot show the google
    calendar.

3) Oauth2 authentication:  This forces login but we cannot provide
    email/pwd automatically here.

4) php curl login to google:   I have
    checked php curl login to google but it is not working and it is no
    more supported (deprecated) by google.
ref:
Login to Google with PHP and Curl, Cookie turned off?

```<code>      Is there any other option to achieve this.
</code>```

答: This isn't going to be possible.  Google won't allow it.  Really, having to know a user's username and password is a bad idea security-wise anyway.  Even if you had this, there are circumstances where it isn't going to work... two factor authentication for example.</p>

Title: Open google calendar with auto login

Body:
Open google calendar with auto login

Requiremment: We want to facility to open a the google calendar with gmail id and pwd without the intervention of the user.So basically it will log out any other user if logged in to google and auto login with provided email and pwd and show the google calendar.

I have already tried following things,

1) Google calendar embed script:   It does not log the user to the
    google if already not logged in and uses which ever the logged in
    users google calendar.

2) Google calendar API:    The google service
    API allows auto authenticate to specific google service account and
    then we can fetch the events but this authentication does not
    actually logs the user to google a/c so we cannot show the google
    calendar.

3) Oauth2 authentication:  This forces login but we cannot provide
    email/pwd automatically here.

4) php curl login to google:   I have
    checked php curl login to google but it is not working and it is no
    more supported (deprecated) by google.
ref:
Login to Google with PHP and Curl, Cookie turned off?

      Is there any other option to achieve this.


问:
Simulate time series from a fitted model
How to simulate a time series from a fitted model with different length?

Here is the R code that I used.

```<code>library(forecast)
x <- rnorm(14)
arima_mtd <- auto.arima(x)
simulate(arima_mtd, future=FALSE, obs=20)
</code>```

The output is

```<code>Time Series:
Start = 1
End = 14
Frequency = 1
 [1]  2.5615390  2.5141284  4.2861222  3.6109683  3.3430394  1.2106125  0.6632493  0.3742014 -0.9513123 -0.3542338  0.5117973 -0.3833429 -0.2657833 -0.8910624
</code>```

Instead of generating 14 observations I want to generate 20 observations from the fitted model.

答:
IMHO, when you have only 14 observations and future = FALSE then you can only generate 14 simulated observations. If you require 20 you wither have to generate 6 more observations by setting future = TRUE:

```<code>a = simulate(arima_mtd, future = FALSE, nsim = 14)
b = simulate(arima_mtd, future = TRUE, nsim = 6)
</code>```

Or you will have to increase the number of observations in your initial x.

Body:
How to simulate a time series from a fitted model with different length?

Here is the R code that I used.

library(forecast)
x <- rnorm(14)
arima_mtd <- auto.arima(x)
simulate(arima_mtd, future=FALSE, obs=20)

The output is

Time Series:
Start = 1
End = 14
Frequency = 1
 [1]  2.5615390  2.5141284  4.2861222  3.6109683  3.3430394  1.2106125  0.6632493  0.3742014 -0.9513123 -0.3542338  0.5117973 -0.3833429 -0.2657833 -0.8910624

Instead of generating 14 observations I want to generate 20 observations from the fitted model.

Body:
IMHO, when you have only 14 observations and future = FALSE then you can only generate 14 simulated observations. If you require 20 you wither have to generate 6 more observations by setting future = TRUE:

a = simulate(arima_mtd, future = FALSE, nsim = 14)
b = simulate(arima_mtd, future = TRUE, nsim = 6)

Or you will have to increase the number of observations in your initial x.