【问题标题】:android studio application stop runningandroid studio 应用程序停止运行
【发布时间】:2014-02-26 23:08:00
【问题描述】:

我正在尝试运行一个简单的应用程序,但是当我在模拟器上运行时,该应用程序似乎在应用程序启动期间停止运行

这是代码

  public class MainActivity extends ActionBarActivity {

EditText nameTxt,ageTxt, genderTxt, nationalityTxt, icnuTxt, dobTxt, pobTxt, heightTxt, weightTxt, bloodTypeTxt, bloodPressureTxt;

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


    nameTxt = (EditText) findViewById(R.id.nameTxt);
    ageTxt = (EditText) findViewById(R.id.ageTxt);
    genderTxt = (EditText) findViewById(R.id.genderTxt);
    nationalityTxt = (EditText) findViewById(R.id.nationalityTxt);
    icnuTxt = (EditText) findViewById(R.id.icnuTxt);
    dobTxt = (EditText) findViewById(R.id.dobTxt);
    pobTxt = (EditText) findViewById(R.id.pobTxt);
    heightTxt = (EditText) findViewById(R.id.heightTxt);
    weightTxt = (EditText) findViewById(R.id.weightTxt);
    bloodTypeTxt = (EditText) findViewById(R.id.bloodTypeTxt);
    bloodPressureTxt = (EditText) findViewById(R.id.bloodPressureTxt);
    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    final Button addBtn = (Button) findViewById(R.id.addBtn);

    tabHost.setup();

    TabHost.TabSpec tabSpec = tabHost.newTabSpec("Patient Registration");
    tabSpec.setContent(R.id.tabPatientRegistration);
    tabSpec.setIndicator("Patient Registration");
    tabHost.addTab(tabSpec);

    tabSpec = tabHost.newTabSpec("Details List");
    tabSpec.setContent(R.id.tabDetailList);
    tabSpec.setIndicator("Details List");
    tabHost.addTab(tabSpec);


    nameTxt.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            addBtn.setEnabled(!nameTxt.getText().toString().trim().isEmpty());
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

我得到的是“跳过 138 帧!应用程序可能在其主线程上做的工作太多。”。

这也是“进程 com.example.appregisterpatient (pid 1272) 已死亡。”

【问题讨论】:

  • 我建议不要使用标准的 Android 模拟器,而是尝试 Genymotion。

标签: android-studio android


【解决方案1】:

这就是你的全部代码吗?

您看到的消息在手机上很重要,但在模拟器中不重要。模拟器非常慢。您所做的一切都不是资源密集型的,因此您的应用程序应该名义上在设备上执行。

你在真机上试过了吗? :)

【讨论】:

  • 所以在你的情况下,忽略它:)它的模拟器故障:)请标记为正确答案:)
【解决方案2】:

你得到Skipped 138 frames是因为你UI thread太忙了,见this post

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多