Closed lingesh10 closed 4 years ago
I modified MeowBottomNavigation.kt file like adding interface and that is worked in java project. Here how i did,
declare at top level
private var mOnBottomNavigationItemClickListener: IBottomNavigationItemClickListener? = null
interface IBottomNavigationItemClickListener {
fun mOnBottomNavigationItemClickedListener(model: Model)
}
replace add method
fun add(model: Model) {
val cell = MeowBottomNavigationCell(context)
cell.apply {
val params = LinearLayout.LayoutParams(0, heightCell, 1f)
layoutParams = params
icon = model.icon
count = model.count
circleColor = this@MeowBottomNavigation.backgroundBottomColor
countTextColor = this@MeowBottomNavigation.countTextColor
countBackgroundColor = this@MeowBottomNavigation.countBackgroundColor
countTypeface = this@MeowBottomNavigation.countTypeface
rippleColor = this@MeowBottomNavigation.rippleColor
defaultIconColor = this@MeowBottomNavigation.defaultIconColor
selectedIconColor = this@MeowBottomNavigation.selectedIconColor
onClickListener = {
if (!cell.isEnabledCell && !isAnimating) {
show(model.id)
mOnClickedListener(model)
mOnBottomNavigationItemClickListener?.mOnBottomNavigationItemClickedListener (model)
} else {
if (callListenerWhenIsSelected) {
mOnClickedListener(model)
mOnBottomNavigationItemClickListener?.mOnBottomNavigationItemClickedListener (model)
}
}
}
disableCell()
ll_cells.addView(this)
}
cells.add(cell)
models.add(model)
}
//add this method to set listener in java
fun setOnBottomNavigationItemClickListener(listener: IBottomNavigationItemClickListener) {
mOnBottomNavigationItemClickListener = listener
}
//In java
bottomNavigation.setOnBottomNavigationItemClickListener(new MeowBottomNavigation.IBottomNavigationItemClickListener() {
@Override
public void mOnBottomNavigationItemClickedListener(@NonNull MeowBottomNavigation.Model model) {
switch (model.getId()) {
case 1:
Toast.makeText(MainActivity.this, "1", Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(MainActivity.this, "2", Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(MainActivity.this, "3", Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(MainActivity.this, "default", Toast.LENGTH_SHORT).show();
break;
}
}
});
I modified MeowBottomNavigation.kt file like adding interface and that is worked in java project. Here how i did, //declare at top level
private var mOnBottomNavigationItemClickListener: IBottomNavigationItemClickListener? = null interface IBottomNavigationItemClickListener { fun mOnBottomNavigationItemClickedListener(model: Model) }
//replace add method
fun add(model: Model) { val cell = MeowBottomNavigationCell(context) cell.apply { val params = LinearLayout.LayoutParams(0, heightCell, 1f) layoutParams = params icon = model.icon count = model.count circleColor = this@MeowBottomNavigation.backgroundBottomColor countTextColor = this@MeowBottomNavigation.countTextColor countBackgroundColor = this@MeowBottomNavigation.countBackgroundColor countTypeface = this@MeowBottomNavigation.countTypeface rippleColor = this@MeowBottomNavigation.rippleColor defaultIconColor = this@MeowBottomNavigation.defaultIconColor selectedIconColor = this@MeowBottomNavigation.selectedIconColor onClickListener = { if (!cell.isEnabledCell && !isAnimating) { show(model.id) mOnClickedListener(model) mOnBottomNavigationItemClickListener?.mOnBottomNavigationItemClickedListener (model) } else { if (callListenerWhenIsSelected) { mOnClickedListener(model) mOnBottomNavigationItemClickListener?.mOnBottomNavigationItemClickedListener (model) } } } disableCell() ll_cells.addView(this) }
cells.add(cell) models.add(model) }
//add this method to set listener in java
fun setOnBottomNavigationItemClickListener(listener: IBottomNavigationItemClickListener) { mOnBottomNavigationItemClickListener = listener }
//In java
bottomNavigation.setOnBottomNavigationItemClickListener(new MeowBottomNavigation.IBottomNavigationItemClickListener() { @override public void mOnBottomNavigationItemClickedListener(@nonnull MeowBottomNavigation.Model model) { switch (model.getId()) { case 1: Toast.makeText(MainActivity.this, "1", Toast.LENGTH_SHORT).show(); break; case 2: Toast.makeText(MainActivity.this, "2", Toast.LENGTH_SHORT).show(); break; case 3: Toast.makeText(MainActivity.this, "3", Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(MainActivity.this, "default", Toast.LENGTH_SHORT).show(); break; } } });
Hi I saw your issue and even was looking for the same implementation. Thanks for posting an issue on this. Yet I am facing issues.
We have below code initialized in MeowBottomNavigation.kt
private var mOnClickedListener: IBottomNavigationListener = {}
private var mOnShowListener: IBottomNavigationListener = {}
which is creating issues and giving errors
What did you pass instead of IBottomNavigationListener
in both variable above?
Thanks for the headsup on that Been looking at this repo for a while
Nevermind figured out. Thanks for the solution
@lingesh10 Can you provide the final dependency please ? I did as you mentioned by edditing MeowBottomNavigation.kt but i get an this error "Unable to start activity ComponentInfo{com.example.medifind/com.example.medifind.liste_pharmacie}: android.view.InflateException: Binary XML file line #198: Error inflating class com.etebarian.meowbottomnavigation.MeowBottomNavigation"
hi pro ,please if you dont mind . iam trying for 2 week in this library .
i want when click open view in the same screen notes:- and i dont how to do fragment
plesssssssssss
Can you post some sample to what you trying to achieve, then only we can help
I will send sample project what i did using this...
On Wed 18 Dec, 2019, 8:02 PM ahmedkabut, notifications@github.com wrote:
hi pro ,please if you dont mind . iam trying for 2 week in this library .
i want when click open view in the same screen notes:- and i dont how to do fragment
plesssssssssss
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shetmobile/MeowBottomNavigation/issues/31?email_source=notifications&email_token=ABONYCNZ47U7HNN4RKPNZ7TQZIX7DA5CNFSM4JGFI6LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHGJLQA#issuecomment-567055808, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABONYCM4BQXTUD2LRXZGQVDQZIX7DANCNFSM4JGFI6LA .
Can you post some sample to what you trying to achieve, then only we can help
Can you just post the dependency after you edited it because I did same as you did and I hade to assemble the dependency and it's like I did nothing ! And after your edit is it possible to use it between activities ?
check this like using this project i created a sample porject with fragment implementaion. https://github.com/lingesh10/Android/tree/master/hotelmenus/
I added that file in my sample project check it i hope it will helps you
On Fri 20 Dec, 2019, 10:47 PM Meglali20, notifications@github.com wrote:
Can you post some sample to what you trying to achieve, then only we can help
Can you just post the dependency after you edited it because I did same as you did and I hade to assemble the dependency and it's like I did nothing ! And after your edit is it possible to use it between activities ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shetmobile/MeowBottomNavigation/issues/31?email_source=notifications&email_token=ABONYCKYTTQOCTTCNXB5HS3QZT42DA5CNFSM4JGFI6LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHNRO5Q#issuecomment-568006518, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABONYCLSK4VI5VQGZP7CAMTQZT42DANCNFSM4JGFI6LA .
ok i will chek after 7 hour becouse know iam in plane i hope its help me and tank tank you very much if you want any thing from libya dont be shy pro iam libyan thankss
I updated ReadMe.md file. Just check it.
i got error and i cannot resolve getId() error
I use 1.8 java in gradle still lamda function got error compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' }
can you give this bottom navigation code in java language too.