setContentView
文件中添加一个mp3文件
如果我使用setContentView(R.layout.yoyo)
“yoyo我的mp3文件名”我收到错误实际上我在“lib”中创建了一个子文件夹作为“raw”,其中放置了我的mp3文件“yoyo”。
所以我给了setContentView(R.raw.yoyo)错误消失但是当我在模拟器中激发时出现错误
Installation failed due to invalid URI!
[2014-07-26 11:35:49 - Firstone] Please check logcat output for more details.
[2014-07-26 11:35:50 - Firstone] Launch canceled!
我的Log cat out put
07-26 18:52:15.958: W/ActivityManager(1263): Activity destroy timeout for ActivityRecord{b2209a10 u0 com.firstone/.Splash t7 f}
07-26 18:52:34.779: W/linker(1756): libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
07-26 18:52:36.829: E/memtrack(1756): Couldn't load memtrack module (No such file or directory)
07-26 18:52:36.829: E/android.os.Debug(1756): failed to load memtrack module: -2
07-26 18:52:38.489: W/linker(1767): libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
07-26 18:52:40.319: E/memtrack(1767): Couldn't load memtrack module (No such file or directory)
07-26 18:52:40.319: E/android.os.Debug(1767): failed to load memtrack module: -2
07-26 18:52:41.219: I/ActivityManager(1263): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.firstone/.Splash} from pid 1767 on display 0
07-26 18:52:41.719: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/SurfaceFlinger(938): glCheckFramebufferStatusOES error 779177132
07-26 18:52:41.729: E/SurfaceFlinger(938): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.729: E/libEGL(938): called unimplemented OpenGL ES API
07-26 18:52:41.879: W/WindowManager(1263): Screenshot failure taking screenshot for (123x164) to layer 21000
07-26 18:52:42.119: I/Choreographer(1263): Skipped 809 frames! The application may be doing too much work on its main thread.
07-26 18:52:42.289: I/Choreographer(1263): Skipped 203 frames! The application may be doing too much work on its main thread.
07-26 18:52:42.459: I/Choreographer(1263): Skipped 142 frames! The application may be doing too much work on its main thread.
07-26 18:52:42.699: I/Choreographer(1263): Skipped 267 frames! The application may be doing too much work on its main thread.
07-26 18:52:42.799: I/Choreographer(1263): Skipped 92 frames! The application may be doing too much work on its main thread.
07-26 18:52:42.989: I/Choreographer(1263): Skipped 31 frames! The application may be doing too much work on its main thread.
07-26 18:52:43.219: I/Choreographer(1263): Skipped 30 frames! The application may be doing too much work on its main thread.
07-26 18:52:43.399: I/Choreographer(1263): Skipped 30 frames! The application may be doing too much work on its main thread.
07-26 18:52:43.519: E/Region(938): Region::boolean_operation(op=7) invalid Rect={60,-10,180,-170}
07-26 18:52:51.949: W/ActivityManager(1263): Launch timeout has expired, giving up wake lock!
07-26 18:52:52.119: E/WindowManager(1263): Starting window AppWindowToken{b20e20d0 token=Token{b22a9080 ActivityRecord{b20e1c08 u0 com.firstone/.Splash t8}}} timed out
我的JAVA代码
package com.firstone;
import android.app.Activity;
import android.os.Bundle;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle GaryNeeds) {
// TODO Auto-generated method stub
super.onCreate(GaryNeeds);
setContentView(R.raw.yoyo);
}
}
我的XML代码
答案 0 :(得分:0)
setContentView应与R.layout中的值一起使用。你不能使用R.raw。
阅读以下文档:
http://developer.android.com/reference/android/app/Activity.html#setContentView(int)