应用程序无法在设备上工作,但适用于模拟器

时间:2013-11-01 20:07:22

标签: android android-emulator

为什么我的应用会在设备上停留几秒后停止?

MainActivity.java

public class MainActivity extends Activity
{
 /** Called when the activity is first created. */

    // The text and button used on the display.

    Button showToast;
    Button about;//text about the app and S Chaos
    Button SCwebsite;
    Button aboutapp;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    showToast = (Button) findViewById(R.id.btnPhotos);
    SCwebsite = (Button) findViewById(R.id.btnChaos);
    about = (Button) findViewById(R.id.btnSynchronized);
    aboutapp = (Button) findViewById(R.id.btnAbout);

    showToast.setOnClickListener(myhandler1);
    SCwebsite.setOnClickListener(myhandler2);
    about.setOnClickListener(myhandler3);
    aboutapp.setOnClickListener(myhandler4);


}

//butoes a funcionar

View.OnClickListener myhandler1 = new View.OnClickListener() {
public void onClick(View v) {
  // it was the 1st button
}};

View.OnClickListener myhandler2 = new View.OnClickListener() {
public void onClick(View v) {
  // it was the 1st button
}};

View.OnClickListener myhandler3 = new View.OnClickListener() {
public void onClick(View v) {
  // it was the 1st button
}};

View.OnClickListener myhandler4 = new View.OnClickListener() {
public void onClick(View v) {
  // it was the 1st button
}};}

为什么会这样? 我的代码非常简单。 设备是4.1.2,我在模拟器4.2.2中进行了测试

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Hello World, SynchronizedChaos"
    />

<Button 
   android:onClick="@+id/btnPhotos"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="View Photos"/>

<Button 
   android:onClick="@+id/btnChaos"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="View Chaos Webpage"/>

<Button 
   android:onClick="@+id/btnSynchronized"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="About Synchronized Chaos"/>

<Button 
   android:onClick="@+id/btnAbout"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="About this App"/>

</LinearLayout>

在log cat中我看到:spannablestringbuilder(2481): span_exclusive_exclusive spans cannot have a zero lenght 和  InputConnectionWrapper(2481)setComposingText在非活动的InputConnection

0 个答案:

没有答案