mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

Override AccountHeaderView #2803

Closed virovinrom closed 7 months ago

virovinrom commented 7 months ago

Can I somehow override AccountHeaderView? I have my own material_drawer_header file with additional button.

I used kotlinx synthetic to refer to this button headerView = AccountHeaderView(ctx).apply { sub_button.visibility = View.VISIBLE } but now I need to migrate to viewbinding and sub_button are now unresolved. How can I manage this issue?

mikepenz commented 7 months ago

You have access to the accountHeader from the AccountHeaderView.

So if the layout includes an additional view, you can find it with the traditional findViewById

virovinrom commented 7 months ago

You have access to the accountHeader from the AccountHeaderView.

So if the layout includes an additional view, you can find it with the traditional findViewById

You think like this accountHeader.findViewById(R.id.sub_button) but I have an error: Not enough information to infer type variable T

mikepenz commented 7 months ago

Please refer to the official docs on how to use platform APIs: https://developer.android.com/reference/android/view/View#findViewById(int)

findViewById requires a type as the error states.

either it can infer the type, or you pass it findViewById<T> where T is your type.

virovinrom commented 7 months ago

Please refer to the official docs on how to use platform APIs: https://developer.android.com/reference/android/view/View#findViewById(int)

findViewById requires a type as the error states.

either it can infer the type, or you pass it findViewById<T> where T is your type.

Am I correct? accountHeader.findViewById<AppCompatButton>(R.id.sub_button)

mikepenz commented 7 months ago

I don't know the type of your button, but yes, something like that :D

virovinrom commented 7 months ago

I don't know the type of your button, but yes, something like that :D

much obliged

mikepenz commented 7 months ago

You are welcome.