package com.android.dbs;import android.app.Activity;
//import android.content.DialogInterface;
//import android.content.DialogInterface.OnClickListener;
//import android.view.View;
//import android.view.View.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
//import android.widget.ListAdapter;public class DanceDemoActivity extends Activity {
    
Button btn_music;

/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        setContentView(R.layout.main);
        
    }
    
   public View.OnClickListener musicOnClickListener = new View.OnClickListener(){ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(DanceDemoActivity.this, MusicList.class);
startActivity(intent);
}
    
    };
    
    public void init(){
     btn_music = (Button) this.findViewById(R.id.btn_game_music);
     btn_music.setOnClickListener(musicOnClickListener);
    }
}
------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/main_1"
    android:orientation="vertical" >
    <Button
        android:id="@+id/btn_game_start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="22dp"
        android:layout_marginTop="43dp"
        android:text="@string/game_start" />    <Button
        android:id="@+id/btn_game_music"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_game_start"
        android:layout_below="@+id/btn_game_start"
        android:text="@string/game_music" />    <Button
        android:id="@+id/btn_game_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_game_music"
        android:layout_below="@+id/btn_game_music"
        android:text="@string/game_background" />
    <Button
        android:id="@+id/btn_game_about"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_game_background"
        android:layout_alignRight="@+id/btn_game_background"
        android:layout_below="@+id/btn_game_background"
        android:text="@string/game_about" />
    <Button
        android:id="@+id/btn_game_exit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_game_about"
        android:layout_alignRight="@+id/btn_game_about"
        android:layout_below="@+id/btn_game_about"
        android:text="@string/game_exit" /></RelativeLayout>

解决方案 »

  1.   

     btn_music.setOnClickListener(musicOnClickListener);
    这句话换成: 
    btn_music.setOnClickListener(new musicOnClickListener());
      

  2.   

    缺少配置文件吧 
    跳转到另一个 activity 要在AndroidManifest.xml 配置
      

  3.   

    <activity android:name="MusicList"></activity>name=类的名字
      

  4.   

    哥init();
    setContentView(R.layout.main);
    这两句 位置写反了。
    请问连配置文件都没加载。你如何找的到控件呢。?? 
      

  5.   

    大概知道了,是因为后面那个Activity的问题,ListView有问题
      

  6.   

    谁有ListView显示手机和SD卡中音频文件的示例?