当我尝试在Android工作室模拟器上运行我的代码时,我一直收到错误。我尝试过任何可以修复的东西,但我是编码和软件的新手。我创建了一个启动画面。 下面是我的Java代码。
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.view.Window
import android.view.WindowManager
class MainActivity : AppCompatActivity() {
val SPLASH_TIME_OUT=3000;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Handler().postDelayed(object:Runnable{
public override fun run(){
val home= Intent (this@MainActivity,EntryScreenActivity::class.java)
startActivity(home)
finish()
}
}, SPLASH_TIME_OUT.toLong())
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="sararafiq94.com.carparkingreservationsystem.MainActivity">
<ImageView
android:id="@+id/applogo"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignBottom="@+id/appname"
android:layout_centerHorizontal="true"
android:layout_marginBottom="69dp"
app:srcCompat="@drawable/applogo" />
<ImageView
android:id="@+id/appname"
android:layout_width="150dp"
android:layout_height="80dp"
android:layout_alignLeft="@+id/applogo"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/applogo"
android:layout_marginBottom="217dp"
app:srcCompat="@drawable/appname" />