android studio应用程序停止运行

时间:2014-02-26 23:08:00

标签: android-studio android

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

这是代码

  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)已经死亡。”

2 个答案:

答案 0 :(得分:1)

这是你的所有代码吗?

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

你在真实设备上试过吗? :)

答案 1 :(得分:0)

由于Skipped 138 frames太忙,您得到UI thread,请参阅this post