尝试在空对象引用上调用虚拟方法‘android.view.Window$回调-android.view.Window.getCallback()’
SplashActivity
LoginActivity
SplashActivity.java
:
package com.example.android.appName;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity; import java.util.Timer;import java.util.TimerTask;public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { Intent intent = new Intent(SplashActivity.this, LoginActivity.class); startActivity(intent); finish(); } }, 1500); }}
LoginActivity.java
:
package com.example.android.appName;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity; import android.view.KeyEvent;import android.view.Menu;import android.view.MenuInflater;import android.view.MenuItem;import android.view.View; import android.widget.EditText;import android.widget.ProgressBar;import android.widget.TextView; public class LoginActivity extends AppCompatActivity { private EditText usernameField = (EditText)findViewById(R.id.username), passwordField = (EditText)findViewById(R.id.password); private TextView error = (TextView)findViewById(R.id.error); private ProgressBar progress = (ProgressBar)findViewById(R.id.progress); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.login_menu, menu); return true; }
莫回无
饮歌长啸