问:
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?

答:
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());

        Fee fee=new Fee();
        fee.getUsersListData();

        //added code
        for (int i = 0; i < ; 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;
    }

    public 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>```

layout_bil_info

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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>
</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:
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());

        Fee fee=new Fee();
        fee.getUsersListData();

        //added code
        for (int i = 0; i < ; 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;
    }

    public 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);
        }
    }

layout_bil_info

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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>


来源: stackexchange

问:
Django Template Foreign Key BooleanField: Get Unread Article
Thank you for taking your time.

I would like to establish a function for users to see which posts they have not read yet and which ones they have.

What I have done: I managed to show what a user has already read.

My Problem: I cannot manage to show a user what he or she has not read. Because An article which has been read by A should still remain "Unread" to B.

My model:

```<code>class Posts(models.Model):
 title = models.CharField(max_length=255)
 content_url = models.URLField(unique=True)
 content = models.CharField(max_length=255)
 post_date = models.DateField(default="2999-12-12")
</code>```

Another

```<code>class readstatus(models.Model):
 reading_status = models.BooleanField(default=False)
 user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
 article = models.ForeignKey(Posts, on_delete=models.CASCADE)
 created = models.DateTimeField(auto_now_add=True)
</code>```

My View:

```<code>class DailyReading(ListView):
model = Posts
template_name = 'reading.html'
context_object_name = "data"
paginate_by = 20
</code>```

My Template:

```<code>{% if "/read/" in request.path %}
    {% for info in data %}
        {% for read in info.readstatus_set.all %}
            {% if request.user == read.user %}
                <quoteblock>
                    <ul>
                        <li><a href="{{ info.get_absolute_url }}">{{ info.title }}
                            <footnote></footnote>
                        </a>{{ info.post_date }}</li>

                        <footnote>{{ info.get_abstract_content }}</footnote>
                    </ul>
                </quoteblock>

            {% endif %}

        {% endfor %}
    {% endfor %}
{% else %}

    {% for info in data %}
        {# NEED HELP HERE, HOW DO I SHOW A UNREAD ARTICLE WHICH HAS BEEN READ BY ANOTHER USER FOR A NEW USER #}
    {% endfor %}

{% endif %}
</code>```

答: I figured out why I cannot get the "unread" feature when I tried to loop the .readstatus_set.all. Because I have data that I wrote into the database without using Django although I set the reading default for each post to False---- there is simply no record. I need to find out how to apply the default value to the existing records, but this is for another topic. </p>

ContentLicense: CC BY-SA 3.0

Body:
Thank you for taking your time.

I would like to establish a function for users to see which posts they have not read yet and which ones they have.

What I have done: I managed to show what a user has already read.

My Problem: I cannot manage to show a user what he or she has not read. Because An article which has been read by A should still remain "Unread" to B.

My model:

class Posts(models.Model):
 title = models.CharField(max_length=255)
 content_url = models.URLField(unique=True)
 content = models.CharField(max_length=255)
 post_date = models.DateField(default="2999-12-12")

Another

class readstatus(models.Model):
 reading_status = models.BooleanField(default=False)
 user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
 article = models.ForeignKey(Posts, on_delete=models.CASCADE)
 created = models.DateTimeField(auto_now_add=True)

My View:

class DailyReading(ListView):
model = Posts
template_name = 'reading.html'
context_object_name = "data"
paginate_by = 20

My Template:

{% if "/read/" in request.path %}
    {% for info in data %}
        {% for read in info.readstatus_set.all %}
            {% if request.user == read.user %}
                <quoteblock>

{{ info.title }}
                            <footnote></footnote>
                        {{ info.post_date }}

                        <footnote>{{ info.get_abstract_content }}</footnote>

                </quoteblock>

            {% endif %}

        {% endfor %}
    {% endfor %}
{% else %}

    {% for info in data %}
        {# NEED HELP HERE, HOW DO I SHOW A UNREAD ARTICLE WHICH HAS BEEN READ BY ANOTHER USER FOR A NEW USER #}
    {% endfor %}

{% endif %}


问:
Exception in the Android's code while starting the app
In the "Crashes and ANRs" of the Google Play Developer console I've got such a report:

```<code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.res.Resources.getAssets()' on a null object reference
at android.app.LoadedApk.getAssets(LoadedApk.java:590)
at android.app.LoadedApk.makeApplication(LoadedApk.java:646)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5088)
at android.app.ActivityThread.access$1600(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
</code>```

The device that has this problem is Galaxy S4 and runs Android 5.0

What it can be - there is not a single line from my code, why does it fail?

Thanks a lot!

答:
I've got this in my console too.
It seems this occurs when users start the app when it's currently being updated or just after that.

A possible workaround would be to check if getResources returns null when the application start, and kill it if it does:

```<code>public class DevToolsApplication extends Application {
    private static final String TAG = "DevToolsApplication";

    @Override
    public void onCreate() {
        super.onCreate();
        AppLogger.i(TAG, "app start...");
        checkAppReplacingState();
    }

    private void checkAppReplacingState() {
        if (getResources() == null) {
            AppLogger.w(TAG, "app is replacing...kill");
            Process.killProcess(Process.myPid());
        }
    }
}
</code>```

See this for more information
https://issuetracker.google.com/issues/36972466

Body:
In the "Crashes and ANRs" of the Google Play Developer console I've got such a report:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.res.Resources.getAssets()' on a null object reference
at android.app.LoadedApk.getAssets(LoadedApk.java:590)
at android.app.LoadedApk.makeApplication(LoadedApk.java:646)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5088)
at android.app.ActivityThread.access$1600(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)

The device that has this problem is Galaxy S4 and runs Android 5.0

What it can be - there is not a single line from my code, why does it fail?

Thanks a lot!

Body:
I've got this in my console too.
It seems this occurs when users start the app when it's currently being updated or just after that.

A possible workaround would be to check if getResources returns null when the application start, and kill it if it does:

public class DevToolsApplication extends Application {
    private static final String TAG = "DevToolsApplication";

    @Override
    public void onCreate() {
        super.onCreate();
        AppLogger.i(TAG, "app start...");
        checkAppReplacingState();
    }

    private void checkAppReplacingState() {
        if (getResources() == null) {
            AppLogger.w(TAG, "app is replacing...kill");
            Process.killProcess(Process.myPid());
        }
    }
}

See this for more information
https://issuetracker.google.com/issues/36972466


问:
Angular2 Material md-sidenav-container causes exception in ng test
Basic use of md-sidenav-container in a fresh ng cli project causes ng test to fail on second and subsequent tests.

Exception

```<code>TypeError: Cannot read property 'unsubscribe' of undefined
        at ScrollDispatcher.deregister (webpack:///~/@angular/material/core/overlay/scroll/scroll-dispatcher.js:52:0 <- src/test.ts:10756:50)
        at Scrollable.ngOnDestroy (webpack:///~/@angular/material/core/overlay/scroll/scrollable.js:28:0 <- src/test.ts:86637:22)
        at Wrapper_Scrollable.ngOnDestroy (/OverlayModule/Scrollable/wrapper.ngfactory.js:13:16)
        at CompiledTemplate.proxyViewClass.View_MdSidenavContainer0.destroyInternal (/MdSidenavModule/MdSidenavContainer/component.ngfactory.js:66:24)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.View_AppComponent0.destroyInternal (/DynamicTestModule/AppComponent/component.ngfactory.js:115:19)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.destroyInternal (/DynamicTestModule/AppComponent/host.ngfactory.js:33:19)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.AppView.detachAndDestroy (webpack:///~/@angular/core/src/linker/view.js:187:0 <- src/test.ts:82480:14)
        at ComponentRef_.destroy (webpack:///~/@angular/core/src/linker/component_factory.js:147:51 <- src/test.ts:40464:70)
        at ComponentFixture.destroy (webpack:///~/@angular/core/bundles/core-testing.umd.js:263:0 <- src/test.ts:21186:35)
</code>```

app.component.html

```<code><div>
  <md-sidenav-container>
    <md-sidenav mode="side" opened="true">Drawer content</md-sidenav>
    <div class="my-content">Main content</div>
  </md-sidenav-container>
</div>
</code>```

app.component.spec.ts

```<code>import {TestBed, async} from '@angular/core/testing';
import {MaterialModule} from '@angular/material';
import {AppComponent} from './app.component';
import 'hammerjs';

describe('AppComponent', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [
        MaterialModule
      ],
      declarations: [
        AppComponent
      ],
    });
    TestBed.compileComponents();
  });

  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));

  // Same test repeated enough to generate exception
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
});
</code>```

package.json (default + material 2.0.0-beta.2)

```<code>{
  "name": "admin",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/router": "^3.4.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.31",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.0"
  }
}
</code>```

app.component.ts

```<code>import {Component, ElementRef, OnInit} from '@angular/core';
import {HostListener} from '@angular/core/src/metadata/directives';
import {AuthService} from './services/auth.service';
import {ConceptService} from './services/concept.service';
import {AppService} from './services/app.service';
import {Router, NavigationStart} from '@angular/router';
import {LocationService} from './services/location.service';
import {ConfigService} from './services/config.service';
import {ToastService} from './services/toast.service';
import {ContextService} from './services/context.service';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
})

export class AppComponent implements OnInit {
  sidenavOpen = true;
  appElement;
  envName = 'default';
  _serverVersion: any = '{}';
  currentRoute = '';

  menuItems = [
    {route: 'home', name: 'Dashboard', icon: 'home'}
  // some lines omitted
    , {route: 'concepts', name: 'Concepts', icon: 'toc'}

  ];

  constructor(elementRef: ElementRef,
              private authService: AuthService,
              private conceptService: ConceptService,
              private configService: ConfigService,
              private locationService: LocationService,
              private appService: AppService,
              private contextService: ContextService,
              private toast: ToastService,
              private router: Router) {
    this.appElement = elementRef.nativeElement;
  }

  ngOnInit(): void {
    this.appService.container = this.appElement.querySelector('.app-content');
    // Warm caches
    Promise.all([
      this.conceptService.getAll(),
      this.configService.getAll(),
      this.locationService.getAll(),
      this.configService.serverVersion().then(ver => this._serverVersion = ver),
      this.contextService.getContext().then(ctx => this.envName = ctx.name.replace(' ', '_').toLowerCase())
    ]).catch(e => this.toast.error(e));

    // Monitor size for handling sidebar
    this.onResize(this.appElement.clientWidth);
    this.router.events.subscribe((event) => {
      if (event instanceof NavigationStart) {
        this.onResize(this.appElement.clientWidth);
      }
    });

    // Log out on closing or or navigating away
    window.onbeforeunload = function () {
      this.authService.logout();
    }.bind(this);
  }

  @HostListener('window:resize', ['$event.target.innerWidth'])
  onResize(w) {
    this.sidenavOpen = w > 500;
  }

  isDisabled(path: string) {
    return !this.authService.isAuthorised(path);
  }
}
</code>```

答:
I do have the same problem. I solved it by making global vars for fixture etc.

```<code>  fdescribe('AppComponent', () => {
    let component: AppComponent;
    let fixture: ComponentFixture<AppComponent>;
    let de: DebugElement;
    let el: HTMLElement;

 beforeEach(() => {
TestBed.configureTestingModule({
  declarations: [
    AppComponent
  ],
  imports:[RouterModule,UiPageHeaderModule,UiAppHeaderModule,RouterTestingModule, MaterialModule.forRoot()],
});
TestBed.compileComponents();
 });

   it('should create the app', async(() => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
 }));

  // Same test repeated enough to generate exception
  it('should create the app', async(() => {
   //const fixture = TestBed.createComponent(AppComponent); no need of this. this is causing the issue,
   const app = fixture.debugElement.componentInstance;
   expect(app).toBeTruthy();
  }));
});
</code>```

Body:
Basic use of md-sidenav-container in a fresh ng cli project causes ng test to fail on second and subsequent tests.

Exception

TypeError: Cannot read property 'unsubscribe' of undefined
        at ScrollDispatcher.deregister (webpack:///~/@angular/material/core/overlay/scroll/scroll-dispatcher.js:52:0 <- src/test.ts:10756:50)
        at Scrollable.ngOnDestroy (webpack:///~/@angular/material/core/overlay/scroll/scrollable.js:28:0 <- src/test.ts:86637:22)
        at Wrapper_Scrollable.ngOnDestroy (/OverlayModule/Scrollable/wrapper.ngfactory.js:13:16)
        at CompiledTemplate.proxyViewClass.View_MdSidenavContainer0.destroyInternal (/MdSidenavModule/MdSidenavContainer/component.ngfactory.js:66:24)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.View_AppComponent0.destroyInternal (/DynamicTestModule/AppComponent/component.ngfactory.js:115:19)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.destroyInternal (/DynamicTestModule/AppComponent/host.ngfactory.js:33:19)
        at CompiledTemplate.proxyViewClass.AppView.destroy (webpack:///~/@angular/core/src/linker/view.js:203:0 <- src/test.ts:82496:14)
        at CompiledTemplate.proxyViewClass.DebugAppView.destroy (webpack:///~/@angular/core/src/linker/view.js:606:0 <- src/test.ts:82899:38)
        at CompiledTemplate.proxyViewClass.AppView.detachAndDestroy (webpack:///~/@angular/core/src/linker/view.js:187:0 <- src/test.ts:82480:14)
        at ComponentRef_.destroy (webpack:///~/@angular/core/src/linker/component_factory.js:147:51 <- src/test.ts:40464:70)
        at ComponentFixture.destroy (webpack:///~/@angular/core/bundles/core-testing.umd.js:263:0 <- src/test.ts:21186:35)

app.component.html

  <md-sidenav-container>
    <md-sidenav mode="side" opened="true">Drawer content</md-sidenav>

Main content

  </md-sidenav-container>

app.component.spec.ts

import {TestBed, async} from '@angular/core/testing';
import {MaterialModule} from '@angular/material';
import {AppComponent} from './app.component';
import 'hammerjs';

describe('AppComponent', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [
        MaterialModule
      ],
      declarations: [
        AppComponent
      ],
    });
    TestBed.compileComponents();
  });

  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));

  // Same test repeated enough to generate exception
  it('should create the app', async(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));
});

package.json (default + material 2.0.0-beta.2)

{
  "name": "admin",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/router": "^3.4.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.31",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.0"
  }
}

app.component.ts

import {Component, ElementRef, OnInit} from '@angular/core';
import {HostListener} from '@angular/core/src/metadata/directives';
import {AuthService} from './services/auth.service';
import {ConceptService} from './services/concept.service';
import {AppService} from './services/app.service';
import {Router, NavigationStart} from '@angular/router';
import {LocationService} from './services/location.service';
import {ConfigService} from './services/config.service';
import {ToastService} from './services/toast.service';
import {ContextService} from './services/context.service';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
})

export class AppComponent implements OnInit {
  sidenavOpen = true;
  appElement;
  envName = 'default';
  _serverVersion: any = '{}';
  currentRoute = '';

  menuItems = [
    {route: 'home', name: 'Dashboard', icon: 'home'}
  // some lines omitted
    , {route: 'concepts', name: 'Concepts', icon: 'toc'}

  ];

  constructor(elementRef: ElementRef,
              private authService: AuthService,
              private conceptService: ConceptService,
              private configService: ConfigService,
              private locationService: LocationService,
              private appService: AppService,
              private contextService: ContextService,
              private toast: ToastService,
              private router: Router) {
    this.appElement = elementRef.nativeElement;
  }

  ngOnInit(): void {
    this.appService.container = this.appElement.querySelector('.app-content');
    // Warm caches
    Promise.all([
      this.conceptService.getAll(),
      this.configService.getAll(),
      this.locationService.getAll(),
      this.configService.serverVersion().then(ver => this._serverVersion = ver),
      this.contextService.getContext().then(ctx => this.envName = ctx.name.replace(' ', '_').toLowerCase())
    ]).catch(e => this.toast.error(e));

    // Monitor size for handling sidebar
    this.onResize(this.appElement.clientWidth);
    this.router.events.subscribe((event) => {
      if (event instanceof NavigationStart) {
        this.onResize(this.appElement.clientWidth);
      }
    });

    // Log out on closing or or navigating away
    window.onbeforeunload = function () {
      this.authService.logout();
    }.bind(this);
  }

  @HostListener('window:resize', ['$event.target.innerWidth'])
  onResize(w) {
    this.sidenavOpen = w > 500;
  }

  isDisabled(path: string) {
    return !this.authService.isAuthorised(path);
  }
}

Body:
I do have the same problem. I solved it by making global vars for fixture etc.

  fdescribe('AppComponent', () => {
    let component: AppComponent;
    let fixture: ComponentFixture<AppComponent>;
    let de: DebugElement;
    let el: HTMLElement;

 beforeEach(() => {
TestBed.configureTestingModule({
  declarations: [
    AppComponent
  ],
  imports:[RouterModule,UiPageHeaderModule,UiAppHeaderModule,RouterTestingModule, MaterialModule.forRoot()],
});
TestBed.compileComponents();
 });

   it('should create the app', async(() => {
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
 }));

  // Same test repeated enough to generate exception
  it('should create the app', async(() => {
   //const fixture = TestBed.createComponent(AppComponent); no need of this. this is causing the issue,
   const app = fixture.debugElement.componentInstance;
   expect(app).toBeTruthy();
  }));
});


问:
upload image to multiple models in rails
I am using carrierwave and Minimagick gem to upload an attachment to S3. Now I want to save the some.pdf in two models(ie, assignment, and message). I give the same parameters in attachment field to save in two tables. But the second table attachment saves blurry. First one gets clear view of attachment.

My controller codes like,

```<code>@assignment = Assignment.new(assignment_params)
@message = Message.new
begin
  Message.transaction do
    asign_att = params[:assignment][:attachment]
    @assignment.save!

    @message.attachment = asign_att
    @message.save!
  end
end
</code>```

My model has,

```<code>(in attachment.rb) mount_uploader :attachment, AttachmentUploader
(in message.rb) mount_uploader :attachment, ImageUploader
</code>```

I want to save same file into two models with clear view. What I want to do? Thanks in advance.

答:
I would use a callback to do this, something like:

```<code>after_commit :assign_to_models

def assign_to_models
  ...
end
</code>```

IMHO, I would create an model that has all the carrierwave attachements, and have it belongs both to message and attachement.

I hope this helps

Body:
I am using carrierwave and Minimagick gem to upload an attachment to S3. Now I want to save the some.pdf in two models(ie, assignment, and message). I give the same parameters in attachment field to save in two tables. But the second table attachment saves blurry. First one gets clear view of attachment.

My controller codes like,

@assignment = Assignment.new(assignment_params)
@message = Message.new
begin
  Message.transaction do
    asign_att = params[:assignment][:attachment]
    @assignment.save!

    @message.attachment = asign_att
    @message.save!
  end
end

My model has,

(in attachment.rb) mount_uploader :attachment, AttachmentUploader
(in message.rb) mount_uploader :attachment, ImageUploader

I want to save same file into two models with clear view. What I want to do? Thanks in advance.

Body:
I would use a callback to do this, something like:

after_commit :assign_to_models

def assign_to_models
  ...
end

IMHO, I would create an model that has all the carrierwave attachements, and have it belongs both to message and attachement.

I hope this helps


问:
C Programming Structures
```<code>#include <stdio.h>

struct temp{
 char b1;
 double a;
 int f;
};
int main()
{
  struct temp temp1;
  int size = 0;

  size = sizeof(temp1);
}
</code>```

why size value is 24 instead of 20?... In 32 bit machine.

Advance Thanks...

答:
```<code>struct temp{
 char b1;  // 1 byte + 7 bytes padding
 double a; // 8 bytes
 int f;    // 4 bytes + 4 bytes padding
};
</code>```

This is because of member padding :)

Title: C Programming Structures

Body:
#include <stdio.h>

struct temp{
 char b1;
 double a;
 int f;
};
int main()
{
  struct temp temp1;
  int size = 0;

  size = sizeof(temp1);
}

why size value is 24 instead of 20?... In 32 bit machine.

Advance Thanks...

Body:
struct temp{
 char b1;  // 1 byte + 7 bytes padding
 double a; // 8 bytes
 int f;    // 4 bytes + 4 bytes padding
};

This is because of member padding :)


问:
How to get specific fields to be shown in the search results?
I'm using ezSearch package installed into Umbraco 7.6.
What I am trying to do is to get specific fields to be always shown in the search result under the pageName that has the word that the user is looking for,

So for example I have two properties in the homepage (heading1 and homeText)

And the code for (search results) in the macro as following:

```<code>@helper RenderContentResult(SearchViewModel model, IPublishedContent result)
{
    <div class="ezsearch-result">
        <h2><a href="@result.Url">@result.Name</a>XX</h2>

        @foreach (var field in model.PreviewFields.Where(field => result.HasValue(field)))
        {
            <p>@Highlight(Truncate(Umbraco.StripHtml(result.GetPropertyValue(field).ToString()), model.PreviewLength), model.SearchTerms)</p>

            break;
        }
    </div>
}
</code>```

Thank you!

答:
Since result is an IPublishedContent you can access whatever property you want, e.g.

```<code>result.GetPropertyValue<string>("homeText")
</code>```

or

```<code>@(result.GetPropertyValue<string>("homeText"))
</code>```

anywhere in RenderContentResult depending on the needed Razor syntax

Body:
I'm using ezSearch package installed into Umbraco 7.6.
What I am trying to do is to get specific fields to be always shown in the search result under the pageName that has the word that the user is looking for,

So for example I have two properties in the homepage (heading1 and homeText)

And the code for (search results) in the macro as following:

@helper RenderContentResult(SearchViewModel model, IPublishedContent result)
{

@result.NameXX

        @foreach (var field in model.PreviewFields.Where(field => result.HasValue(field)))
        {

@Highlight(Truncate(Umbraco.StripHtml(result.GetPropertyValue(field).ToString()), model.PreviewLength), model.SearchTerms)

            break;
        }

}

Thank you!

Body:
Since result is an IPublishedContent you can access whatever property you want, e.g.

result.GetPropertyValue<string>("homeText")

or

@(result.GetPropertyValue<string>("homeText"))

anywhere in RenderContentResult depending on the needed Razor syntax