2011-11-29 86 views
0

我写了我的代码编译干净和罚款,并说没有错误。我在市面上发布的其他应用程序中使用了相同的代码。我更新ADT时出现问题。我阅读了关于逐步清理的帖子,获取最新的更新,没有任何工作适用于我的应用。它不会播放原始文件中的声音。它的行为就像他们不是原始文件夹。它编译没有问题,但不播放MP3。任何帮助,将不胜感激。从原始文件夹中播放mp3文件的问题

+0

你得到与此相关的任何消息logcat中?你可以发布你用来阅读/播放文件的代码吗? – Craigy

+0

我如何看到logcat,我刚升级到靛蓝试图解决这个问题? –

+0

转到'DDMS'的视角和'窗口 - >显示视图 - > LogCat' – Craigy

回答

0

公共类UpdatecodeActivity延伸活动{

MediaPlayer mp1, mp2; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    mp1 = MediaPlayer.create(this, R.raw.wait); 
    mp2 = MediaPlayer.create(this, R.raw.primates); 

    //Button coding for menu and items 
    Button btn1 = (Button) findViewById(R.id.btn1); 
    registerForContextMenu(btn1); 
    btn1.setOnClickListener(this); 
    Button btn2 = (Button) findViewById(R.id.btn2); 
    registerForContextMenu(btn2); 
    btn2.setOnClickListener(this); 
}//Closing tag for OnCreate 

//OnClick handler for multiple buttons 
public void onClick(View v){ 
    if (v.getId() == R.id.btn1) { 
     // action to perform on button 1 

     mp1.start(); 

    } else if (v.getId() == R.id.btn2) { 
     // action to perform on button 1 

     mp2.start(); 


    }//Closes Onclick Switches 
}//Closes onclick 
+0

确定找到了错误,我没有把onclicklistener放到应用程序中,所以我可以按下按钮一百万次而没有任何东西。感谢你的logcat,我永远不会想到它。 –