apk运行失败!!!
package com.example.apk001;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.os.Build;
public abstract class MainActivity <ToggleButton, ImageView> extends ActionBarActivity implements OnCheckedChangeListener{
private ToggleButton Button;
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button = (ToggleButton) findViewById(R.id.toggleButton1);
img = (ImageView) findViewById (R.id.imageView1);
((CompoundButton) Button).setOnCheckedChangeListener(this);
}
public void OnCheckedChangeListener(CompoundButton button,boolean isChecked)
{
((View) img).setBackgroundResource(isChecked?R.drawable.img01:R.drawable.img02);
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ToggleButton
android:checked="false"
android:textOn="开"
android:textOff="关"
android:id="@+id/toggleButton1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img01"
/>
</LinearLayout>