新人刚接触安卓,做了个功能有异常 求大神指点
启动应用首先会显示图片 然后再跳转页面,出现异常,上异常和代码
SplashActivity 类
private final int SPLASH_DISPLAY_LENGHT = 3000; //延迟三秒
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉应用标题
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
Intent mainIntent = new Intent(SplashActivity.this,MainActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
}
splash.xml
<?xml version= "1.0" encoding = "utf-8"?>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<imageview
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix"
android:src="@drawable/splash" />
</linearlayout>
跳转到MainActivity类 (默认生成的Activity类)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉应用标题
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
异常
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yn.pindiao/com.yn.pindiao.demo.SplashActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class linearlayout
------解决思路----------------------
没有linearlayout
只有LinearLayout,大小写区分