Your custom cookie view is missing one of the default required views
Suvam-Dawn opened this issue · 1 comments
Suvam-Dawn commented
Your custom cookie view is missing one of the default required views.
When i add custom layout, i got this error.
CookieBar.build(DancingFrameActivity.this)
.setCustomView(R.layout.devices_list)
.setCustomViewInitializer(new CookieBar.CustomViewInitializer() {
@Override
public void initView(View v) {
devicelist = v.findViewById(R.id.listView);
pairedDevices = myBluetooth.getBondedDevices();
ArrayList list = new ArrayList();
if (pairedDevices.size() > 0) {
for (BluetoothDevice bt : pairedDevices) {
list.add(bt.getName() + "\n" + bt.getAddress()); //Get the device's name and the address
}
} else {
Toast.makeText(getApplicationContext(), "No Paired Bluetooth Devices Found.", Toast.LENGTH_LONG).show();
}
final ArrayAdapter adapter = new ArrayAdapter(DancingFrameActivity.this, android.R.layout.simple_list_item_1, list);
devicelist.setAdapter(adapter);
}
})
.setAction("Close", new OnActionClickListener() {
@Override
public void onClick() {
CookieBar.dismiss(DancingFrameActivity.this);
}
})
.setEnableAutoDismiss(false)
.setSwipeToDismiss(false)
.setCookiePosition(CookieBar.BOTTOM)
.show();
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Paired Devices"
android:id="@+id/textView"
android:drawableLeft="@drawable/ic_bluetooth"
android:drawablePadding="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/textView" />
</RelativeLayout>
AviranAbady commented
Hello @Suvam-Dawn,
The current version of CookieBar2, assumes you will create a custom view while keeping all the required original views with the correct IDs.
In future versions I will remove that requirement but for now, your custom layout must contain a
- Root Layout (LinearLayout/Relative/Constraint/etc) with id
R.id.cookie
- TextView with id
R.id.tv_title
- TextView with id
R.id.tv_message
- ImageView with id
R.id.iv_icon
- Button with id
R.id.btn_action
All the uncessery views can set visibility to View.GONE
if you don't need them in your custom cookie.