Closed goldmont closed 7 years ago
Hi, please send a minimal sample app where you're able to reproduce the issue. Right now I'm not sure what I need to know so I best have everything at hand.
Good morning! Here you are: https://www.dropbox.com/s/8ph0pd1r1zivpkx/Peppe130Sample.zip?dl=0
Source of android.support.v7.preference.Preference
:
public void onBindViewHolder(PreferenceViewHolder holder) {
holder.itemView.setOnClickListener(mClickListener);
holder.itemView.setId(mViewId);
....
}
where mViewId
is
private int mViewId = 0;
assignable by Preference.setViewId(int)
.
I haven't found where it's used. Haven't look that hard either :D
holder.itemView
.and on unrelated note
m
as in LinearLayout mPreferenceContainer
or LinearLayout.LayoutParams mParams
. M stands for member, these are local variables not class members.Now that this is fixed, you'll have to work on a custom divider implementation because AppCompat divider is full bleed and doesn't respect your margin.
In fact you shouldn't need to extend a Preference class just to work with space around the views. Create an ItemDecoration and override getItemOffsets. Let me know if you get stuck on this.
EDIT: Parent of CardView should have android:clipChildren="false" and
android:clipToPadding="false"` to draw the shadow properly. Maybe even the RecyclerView should
setClipChildren(false)` because the shadow is cut off now.
It works fine now! Thank you again for all the help you are giving me!
Hi,
after I have upgraded to 25.3.1 support libraries, my App crashes when I try to get a LinearLayout using the findViewById method in the onBindViewHolder. The returned View is always null even if it's not. I don't know why this happens but I can confirm that the code worked like a charm using 23.2.0 support libraries.
This is my custom CheckBoxPreference:
This is my custom preference layout (It is the same as yours. I've only wrapped it with a LinearLayout and a CardView):
My goal is to get the LinearLayout whose ID equals to preference_container in order to set a Margin to it. Hoping in your help!