How to change layout id of ChatView?
anonym24 opened this issue · comments
Layout for Chat view is hardcoded https://github.com/chat-sdk/chat-sdk-android/blob/master/chat-sdk-core-ui/src/main/java/sdk/chat/ui/views/ChatView.java#L88
There is no method like:
@Override
protected int getLayout() {
return R.layout.custom_layout;
}
Why?
<attr name="incomingReplyBackgroundColor" format="reference|color" />
<attr name="outcomingReplyBackgroundColor" format="reference|color" />
these attributes aren't used in the library, it's not possible to change background color of messages
from
its outcomingDefaultBubbleColor
and incomingDefaultBubbleColor
this project is weird...
@thecmart I have created a new my Chat Activity ( MyChatActivity extends ChatActivity) and override xml layout with my chat layout(activity_my_chat_activity.xml).
Now I want to change chat layout design and have created a new chatview class as per doc
public class MyChatView extends ChatView {
public MyChatView(Context context) {
super(context);
}
}
and set in a layout, but not showing an error is- can you please make me correct, what I m doing wrong?
Process: com.ncntechnology.winkndrink.test, PID: 17025
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ncntechnology.winkndrink.test/com.ncntechnology.winkndrink.ui.chatsdk.MyChatActivity}: android.view.InflateException: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Error inflating class com.ncntechnology.winkndrink.ui.chatsdk.MyChatView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Error inflating class com.ncntechnology.winkndrink.ui.chatsdk.MyChatView
Caused by: android.view.InflateException: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Error inflating class com.ncntechnology.winkndrink.ui.chatsdk.MyChatView
Caused by: java.lang.NoSuchMethodException: com.ncntechnology.winkndrink.ui.chatsdk.MyChatView.<init> [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructor0(Class.java:2332)
at java.lang.Class.getConstructor(Class.java:1728)
at android.view.LayoutInflater.createView(LayoutInflater.java:828)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at sdk.chat.ui.activities.BaseActivity.onCreate(BaseActivity.java:93)
at sdk.chat.ui.activities.ChatActivity.onCreate(ChatActivity.java:119)
at com.ncntechnology.winkndrink.ui.chatsdk.MyChatActivity.onCreate(MyChatActivity.java:21)
at android.app.Activity.performCreate(Activity.java:7893)
at android.app.Activity.performCreate(Activity.java:7880)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
This isn't a Chat SDK problem, it's a straightforward Android development issue. The error message tells you what is going on.
Caused by: android.view.InflateException: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Error inflating class com.ncntechnology.winkndrink.ui.chatsdk.MyChatView
Caused by: android.view.InflateException: Binary XML file line #19 in com.ncntechnology.winkndrink.test:layout/activity_my_chat_activity: Error inflating class com.ncntechnology.winkndrink.ui.chatsdk.MyChatView
Caused by: java.lang.NoSuchMethodException: com.ncntechnology.winkndrink.ui.chatsdk.MyChatView.<init> [class android.content.Context, interface android.util.AttributeSet]
When I Google that error I find:
You have a custom view referenced in your layout XML, and the custom view doesn't have the required public constructor that takes in Context,AttributeSet arguments.
I guess that you have to add this to your class:
public ChatView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ChatView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
But this is just a guess since I can't see your code ;)
I got it, Thanks for the reply.