简体   繁体   English

活动打开非常缓慢

[英]Activity is opening very slowly

for some reason my activity is opening slowly, do you think that you can help me here?由于某种原因,我的活动开始缓慢,您认为您可以在这里帮助我吗? Now, this is not the only code in Java class, I have 30 buttons that are exactly the same like the one below, only their ID is different since I have 30 card views (widget) in the activity, here is the picture of the design.现在,这不是 Java class 中的唯一代码,我有 30 个按钮与下面的完全相同,只是它们的 ID 不同,因为我在活动中有 30 个卡片视图(小部件),这是图片设计。 I also reduced the pictures to the right size for the card, but that did not help.我还将图片缩小到适合卡片的大小,但这并没有帮助。 May you please help me?你能帮帮我吗?

在此处输入图像描述

Java Class: Java Class:

private Button crkvaspip;

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_zavrsenilista);



        //Dashboard

        crkvaspip = (Button) findViewById(R.id.crkvaspip);
        crkvaspip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) { openCrkvaSvetogPetraIPavla();
            }
        });

 public void openCrkvaSvetogPetraIPavla(){

        Intent intent = new Intent(zavrseni_category.this, bioskop_class.class);
        startActivity(intent);
    }

Android widget card view code: Android 小部件卡片查看代码:

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="210dp"
            app:cardCornerRadius="20dp"
            android:layout_margin="8dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/thumbnail"
                    android:layout_width="match_parent"
                    android:layout_height="170dp"
                    android:layout_alignParentTop="true"
                    android:scaleType="centerCrop"
                    android:adjustViewBounds="true"
                    android:src="@drawable/bioskop1" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/thumbnail"
                    android:maxLines="1"
                    android:padding="8dp"
                    android:fontFamily="@font/baloo"
                    android:text="3D Bioskop"
                    android:textColor="#222"
                    android:textSize="20dp" />

                <Button
                    android:id="@+id/crkvaspip"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#00000000" />


            </RelativeLayout>
        </androidx.cardview.widget.CardView>

UPDATE LOGCAT INFO CODE:更新 LOGCAT 信息代码:

2022-08-28 20:21:51.524 4585-4629/com.visit.bp I/OpenGLRenderer: Davey! duration=4111ms; Flags=1, IntendedVsync=38769851610176, Vsync=38773584943360, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=38773585749700, AnimationStart=38773585821500, PerformTraversalsStart=38773586648100, DrawStart=38773756771500, SyncQueued=38773757001800, SyncStart=38773757217800, IssueDrawCommandsStart=38773825367800, SwapBuffers=38773938657200, FrameCompleted=38773963626600, DequeueBufferDuration=332000, QueueBufferDuration=535000, 

If the emulator is slow, have you tried disabling your antivirus?如果模拟器很慢,您是否尝试过禁用防病毒软件? Another possibility is to optimize the local images, there are programs such as the free website: https://www.iloveimg.com/ and speed up loading.另一种可能是优化本地图片,有免费网站: https://www.iloveimg.com/等程序,加快加载速度。

Another idea would be to distribute the images in other tabs or activities, because your activity may be overloaded, or load them through other libraries like picasso (I believe it has already been mentioned).另一个想法是将图像分发到其他选项卡或活动中,因为您的活动可能会超载,或者通过 picasso 等其他库加载它们(我相信已经提到过)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM