1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="15dp" android:focusable="true" android:focusableInTouchMode="true" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.design.widget.TextInputLayout android:id="@+id/setView" android:layout_width="100dp" android:layout_height="match_parent" app:layout_constraintHorizontal_weight="1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@id/weightView" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <android.support.design.widget.TextInputEditText android:id="@+id/set" android:layout_width="match_parent" android:layout_height="match_parent" android:enabled="false" android:textColor="#000000" android:hint="세 트"/> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:id="@+id/weightView" android:layout_width="100dp" android:layout_height="match_parent" app:layout_constraintHorizontal_weight="1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toLeftOf="@+id/imageView" app:layout_constraintLeft_toRightOf="@+id/setView" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <android.support.design.widget.TextInputEditText android:id="@+id/weight" android:layout_width="match_parent" android:layout_height="match_parent" android:enabled="false" android:textColor="#000000" android:hint="무 게"/> </android.support.design.widget.TextInputLayout> <ImageView android:id="@+id/imageView" android:layout_width="50dp" android:layout_height="60dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@+id/weightView" app:layout_constraintRight_toLeftOf="@+id/numView" app:srcCompat="@drawable/icon_x" /> <android.support.design.widget.TextInputLayout android:id="@+id/numView" android:layout_width="100dp" android:layout_height="match_parent" app:layout_constraintHorizontal_weight="1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toRightOf="@+id/imageView" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> <android.support.design.widget.TextInputEditText android:id="@+id/num" android:layout_width="match_parent" android:layout_height="match_parent" android:enabled="false" android:textColor="#000000" android:hint="횟 수"/> </android.support.design.widget.TextInputLayout> </android.support.constraint.ConstraintLayout> | cs |
지금 두가지 문제가 생겼습니다.수정 기능을 만드는데 수정은 잘됩니다만..수정완료하면 저기 이미지 아이콘이 사라집니다...
이미지 어떻게 넣어야할지 모르겠어요.. 수정하는 소스코드에서 inflater로 수정하는 다이얼로그의 값들을 얻어오는거라 거기는 이미지 아이콘이 없어서
아이디 값을 전혀 얻을 수가없어요..이거 어떻게해야하죠?
또한가지는 첨에 입력을 완료하고 수정이나 삭제를하려면 터치를 길게하면되는데 문제가
첨에 터치가 안되길래 이상하다 싶어서 이곳저곳 건드려보니 두번째사진의 빨간색친 부분정도에서 기능이 작동합니다..당황스럽게 그지없는데
이건 뭐가 잘못된걸까요..?
터치 문제는 XML에서 height 설정 잘못된 것 같고.
height 문제 맞는지 모르겠어요 모든 뷰를 wrap으로도 해보고 match로도해봤는데 똑같아요..ㅜㅜ
아이콘은 터치가 잘먹는데 저기 나머지 뷰들이 위에서 먹네요..
코드를 안 올리고 물어보면 보는 사람이 추측해서 답변할 수 밖에 없음, 어쨋든 추측하자면 터치가 먹힌다면 ClickListener에서 target이 문제 없이 잘 전달되고 있다는 것일테고 결국은 저 부분만 눌렀을 때 popup window가 뜨는 것이니 XML 문제일 것이라고 생각함
선생님 코드 올렸는데 봐주실수 있나요? 근데 수정하고보니 가운데로 보이네요 ㅠㅠ
전체 widget을 LinearLayout(수평)으로 묶어라.
그리고 왜 위에 터치 길게 했을 때만 popup window가 뜨냐면 "numView", "setView", "weightView"를 "num", "set"으로 덮고 있어서 그럼
결국 "num", "set"이 위치하는 곳을 길게 눌렀냐 아니면 짧게 눌러서 입력을 하려고 했느냐 구분을 못하는 것임 뭐 로직은 본인이 짜길 바람.
선생님 꼭 리니어로 바꿔야하나요?
그리고 두번째 질문.. numView나 setView, weightView가 num, set, weight를 덮는게 아니라 반대인가요?
height가 동일한 widget인데 묶어주는게 좋음 LinearLayout(horizontal) 쓰고, num, set, weight가 numView, setView를 덮는다는 거임
LinearLayout 안에 widget이 들어가 있을 때 widget을 누르면 widget이 클릭되지 LinearLayout이 클릭되진 않잖음 ? widget이 아닌 LinearLayout 빈 공간에서 누를 경우 당연히 LinearLayout이 클릭되는 것이고
흠 아직 덮는다는 개념이 잘 이해가 가질않는데..xml 코드상으로보면 TexInputEditText가 TextInputLayout 안에 있어서 TextInputLayout이 EditText를 덮는다는 다고 이해를 했는데 헷갈리네요
도화지에 직사각형 하나 그리고 직사각형 안에 "버튼"이라고 적고 직사각형 검은색으로 채워보셈. 그리고 그 직사각형(버튼)을 손으로 눌러보고 생각해보셈
도화지에서 직사각형(버튼)을 누를 때 사실적으로 말하면 도화지를 누르는 것도 맞고 직사각형(버튼)을 누르는 것이 맞음, 하지만 도화지에 ClickListener 추가했을 때는 오로지 도화지"만" 눌러졌을 때 인식하게 돼 있음 직사각형에 ClickListener를 추가하면 직사각형(버튼)만 눌러졌을 때 인식하는 것임
앱에서 뭔가를 누르면 View라는 것을 통해 전달이 되는데 님이 버튼을 누르면 화면 최상단에서 버튼까지 하나하나 터치가 이동되는 방식임
https://developer.android.com/guide/topics/ui/ui-events?hl=ko
여기 참조하셈
감사합니다..하나하나 따라가면서 보고 있습니다..ㅜㅜ
하움..잘안되네요..ㅜㅜ
안에 edit의 아이디와 겉에 TextInputlayout의 id 두개다 가져왔는데도 안되네용 ㅠㅠ