【问题标题】:My application is working slowly on smartphones我的应用程序在智能手机上运行缓慢
【发布时间】:2017-05-09 16:55:33
【问题描述】:

我是 Android 的初学者程序员,当我创建一个应用程序并将其安装在我的真实手机或其他手机上时,它的运行速度非常慢(我不谈论模拟器)。 - 文件大小仅为 3 MB - 这发生在我制作的所有应用程序中 - 我在构建之前清理了缓存和项目 我安装应用程序的设备:HTC630、三星 galexy S7、三星 Duos j1。 有什么想法吗?

           <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bcc">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="495dp"
        android:orientation="vertical"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent">


        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/edge"
            android:layout_marginTop="@dimen/edge"
            android:text="Enter your name:"
            android:textColor="#FFFFFF"
            android:textSize="@dimen/fsize"
            android:textStyle="bold"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="0dp" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/edge"
            android:ems="10"
            android:inputType="textPersonName"
            android:textColor="#FFFFFF"
            android:textSize="@dimen/fsize"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="0dp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/edge"
            android:layout_marginRight="@dimen/edge"

            android:onClick="nxt"
            android:text="Next"
            android:textSize="@dimen/fsize"
            tools:layout_editor_absoluteX="38dp"
            tools:layout_editor_absoluteY="0dp" />
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

java代码:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void nxt(View view) {

        EditText name =(EditText)findViewById(R.id.editText2);
        Intent txtint= new Intent(this,Main2Activity.class);
        Bundle b = new Bundle();

        b.putString("user",name.getText().toString());
        txtint.putExtras(b);


        startActivity(txtint);
    }
}

【问题讨论】:

  • 您需要提供一些信息才能继续。您可能在代码中做的不好。
  • 你的第一个活动很轻,没有风险。从未使用过android.support.constraint.ConstraintLayout,但我认为这不会杀死性能。那么你在第二个活动中做什么,当然,什么是慢的?那么在模拟器中呢?
  • 按钮,加载活动,写入,一切都很慢..有人告诉我问题可能是由于内存堆造成的..但我真的不知道如何更改它

标签: java android mobile-application


【解决方案1】:

最后我解决了这个问题..我在调整背景大小(以适应屏幕)时出错了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    相关资源
    最近更新 更多