Guest User

Untitled

a guest
Jul 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <LinearLayout
  2. android:id="@+id/layout_add"
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="horizontal">
  7.  
  8. <EditText
  9. android:id="@+id/editTextWeightValue"
  10. android:layout_width="0dp"
  11. android:layout_height="32dp"
  12. android:drawableRight="@drawable/down"
  13. android:background="@drawable/background_edit_text"
  14. android:clickable="true"
  15. android:layout_marginLeft="22dp"
  16. android:layout_marginRight="10dp"
  17. android:inputType="number"
  18. android:layout_weight="1"/>
  19. </LinearLayout>
  20.  
  21. <?xml version="1.0" encoding="utf-8"?>
  22. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  23. android:layout_height="match_parent"
  24. android:layout_width="match_parent"
  25. xmlns:app="http://schemas.android.com/apk/res-auto">
  26. <RelativeLayout
  27. android:id="@+id/rlForAdd"
  28. android:layout_width="match_parent"
  29. android:layout_height="wrap_content">
  30. </RelativeLayout>
  31. </ScrollView>
  32.  
  33. @Override
  34. public void onClick(View view) {
  35.  
  36. LinearLayout linearLayout = new LinearLayout(getApplicationContext());
  37. linearLayout = findViewById(R.id.layout_add);
  38. RelativeLayout relativeLayout = findViewById(R.id.rlForAdd);
  39.  
  40. switch (view.getId()) {
  41.  
  42. case R.id.btnAdd:
  43.  
  44. imageViewRemove.setVisibility(View.VISIBLE);
  45.  
  46. linearLayoutList.add(linearLayout);
  47.  
  48. relativeLayout.addView(linearLayoutList.get(COUNT));//добавляем новый лл из списка
  49.  
  50. COUNT++;
  51. break;
  52.  
  53. E/AndroidRuntime: FATAL EXCEPTION: main
  54. Process: ru.involta.cooklook, PID: 2102
  55. java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup
  56. at android.view.ViewGroup.addView(ViewGroup.java:3718)
  57. at android.view.ViewGroup.addView(ViewGroup.java:3700)
  58. at com.example.a123.project_of_recepts.AddReceipt.onClick(AddReceipt.java:329)
  59. at android.view.View.performClick(View.java:4780)
  60. at android.view.View$PerformClick.run(View.java:19866)
  61. at android.os.Handler.handleCallback(Handler.java:739)
  62. at android.os.Handler.dispatchMessage(Handler.java:95)
  63. at android.os.Looper.loop(Looper.java:135)
  64. at android.app.ActivityThread.main(ActivityThread.java:5254)
  65. at java.lang.reflect.Method.invoke(Native Method)
  66. at java.lang.reflect.Method.invoke(Method.java:372)
  67. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  68. at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  69. I/Process: Sending signal. PID: 2102 SIG: 9
Add Comment
Please, Sign In to add comment