好吧,我知道我在接受率方面并不是最好的...而且我会弥补这一点......那就是说。
我已经关注了TON of Splash Screen教程并且想到我有一些可行的东西......但是,声音不起作用......每当我完成时我都会得到错误“无法解决或者不能解决字段“
任何建议:这里是COMPLETE SplashScreen.java代码:
package com.droidnova.android;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.MotionEvent;
import android.R;
public class SplashScreen extends Activity {
protected boolean _active = true;
protected int _splashTime = 5000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
MediaPlayer mpSplash = MediaPlayer.create(this, R.raw.laugh);
mpSplash.start();
// thread for displaying the SplashScreen
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
finish();
startActivity(new Intent("com.droidnova.android.splashscreen.MyApp"));
stop();
}
}
};
splashTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
}
有什么建议吗?
UPDATE!
以下是AndroidManifest.xml电影的代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.droidnova.android"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".SplashScreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyApp">
<intent-filter>
<action android:name="com.droidnova.android.splashscreen.MyApp" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>
第5行和第6行出错:
第5行:error: Error: No resource found that matches the given name (at 'label' with value '@string/ app_name').
第6行:error: Error: No resource found that matches the given name (at 'label' with value '@string/ app_name').
添加了R.java:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.droidnova.android;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int textView1=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int splash=0x7f030001;
}
public static final class string {
public static final int app_name=0x7f040000;
public static final int main_screen=0x7f040001;
public static final int splash_screen=0x7f040002;
}
}
答案 0 :(得分:1)
尝试删除import android.R;
。
答案 1 :(得分:1)
确保res/raw
文件夹中有一个名为“笑”的文件。
答案 2 :(得分:1)
您应该继续并包含实际的构建错误,但我怀疑您更改了类包,而不是AndroidManifest.xml文件中的包名。 AndroidManifest.xml文件中的包名是什么?
编辑:该软件包名称应与类软件包(com.droidnova.android
)完全相同,否则您将获得构建时解析错误。
答案 3 :(得分:1)
假设您已在Eclipse中自动构建,并且删除R.java并且重建没有解决您的问题,我可以想到导致此问题的一件事是,如果您在XML文档打开时尝试运行该应用程序。检查资源中的任何额外*.out.xml
个文件(例如main.out.xml
)。如果你发现其中任何一个,删除它们,清理你的项目(项目&gt;清洁......),看看这是否解决了这个问题。