0

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

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 中测试过

主要的.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>

在日志中我看到:spannablestringbuilder(2481): span_exclusive_exclusive spans cannot have a zero lenght 和 InputConnectionWrapper(2481) setComposingText on inactive InputConnection

4

0 回答 0