私はアンドロイドスタジオを使ってメッセージングアプリケーションを構築しました。このためにこのクラスをインポートしました。Androidスタジオに新しいメソッドが追加されましたロックされたクラス
import co.devcenter.androiduilibrary.ChatView;
このクラスには、メッセージの送受信オプションがあります。受信メッセージメソッドでは、現在の時刻をとり、メッセージを受信します。さて、私はこのメッセージを保存し、それらをユーザーに見せたいと思います。問題は、このメッセージをユーザーに表示するには、このメッセージの時刻を格納するStoreMessagesのようなメソッドを記述する必要があります。ユーザーにこのメッセージを表示する場合は、時間をcompenentと同等にする必要があります。私はデータベース上の価値があります。しかし、私は受信メソッドを変更することができないので、常に現在の時間がかかります。どうすればこのクラスに新しい機能を追加できますか?
私は、私が作成した新しいJavaファイルにクラス全体をコピーしようとした私のプログラムは、これが興味を持ったもののログ猫のエラーですが、この質問の主な焦点は、私が尋ねたものを達成する方法である
を墜落。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sahilliolu.myapplication/com.example.sahilliolu.myapplication.ChatActivity}: java.lang.ClassCastException: co.devcenter.androiduilibrary.ChatView cannot be cast to com.example.sahilliolu.myapplication.ChatView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassCastException: co.devcenter.androiduilibrary.ChatView cannot be cast to com.example.sahilliolu.myapplication.ChatView
at com.example.sahilliolu.myapplication.ChatActivity.onCreate(ChatActivity.java:38)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
、私はそれを追加していますが、私の質問は、私はあなたが二つの異なる 'ChatView'クラスを持っている –
にlogcatを追加します。あなたは他の人にキャストすることはできません。あなたは混乱を避けるために 'com.example.sahilliolu.myapplication.ChatView'の名前を変えるべきです – Prethia
を取得し、エラーに関するものではありませんあなたの質問 –