I have problems with Handler and Looper

221 views Asked by At

My project consists of two parts 1 and 2.

  1. in Maine Activity recorded data, then pressed to the Save button (data stored in Firerbase).
  2. Next, we pressed the button to read, and we opened a window with a list, then when you click on a dumb object, we opened a new window with a deployed description.

The first part works, and the second doesn't, the program crashes and shows the following error:

LogCat

   2022-05-12 14:52:30.530 9756-9756/com.example.t3 E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.t3, PID: 9756
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.t3/com.example.t3.ReadActivity}: android.view.InflateException: Binary XML file line #19 in com.example.t3:layout/activity_read: addView(View, LayoutParams) is not supported in AdapterView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
            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:2066)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:223)
            at android.app.ActivityThread.main(ActivityThread.java:7656)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
         Caused by: android.view.InflateException: Binary XML file line #19 in com.example.t3:layout/activity_read: addView(View, LayoutParams) is not supported in AdapterView
         Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
            at android.widget.AdapterView.addView(AdapterView.java:515)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
            at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
            at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
            at com.example.t3.ReadActivity.onCreate(ReadActivity.java:33)
            at android.app.Activity.performCreate(Activity.java:8000)
            at android.app.Activity.performCreate(Activity.java:7984)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
            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:2066)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:223)
            at android.app.ActivityThread.main(ActivityThread.java:7656)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
  @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_read);
    init();
    getDataFromDb();
    setOnClickItem();
}
0

There are 0 answers