weex开发时,我们一般不用we页面来做欢迎也,主要是weex早期版本不支持本地图片,最新版本支持,但我觉得原生实现是最好的选择。
实现效果如下图:
代码如下
public class SplashActivity extends Activity{ PRivate static final long SPLASH_DELAY_MILSS = 2000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); SharedPreferences sp = getSharedPreferences("userinfo",MODE_WORLD_WRITEABLE); String username = sp.getString("username",""); String un = "暴走漫画"; if(username.equals(un)){ new Handler().postDelayed(new Runnable() { @Override public void run() { goMain(); } },SPLASH_DELAY_MILSS);} else { new Handler().postDelayed(new Runnable() { @Override public void run() { goLogin(); } },SPLASH_DELAY_MILSS); } } private void goMain(){ Intent intent = new Intent(SplashActivity.this,HomeActivity.class); startActivity(intent); SplashActivity.this.finish(); } private void goLogin(){ Intent intent = new Intent(SplashActivity.this,LoginActivity.class); startActivity(intent); SplashActivity.this.finish(); }}跳到下一个activity是用mInstance.render("WeexQuickStart", WXFileUtils.loadAsset(URL, this), null, null, -1, -1, WXRenderStrategy.APPEND_ASYNC);来加载js,用URL指定加载哪个js。项目源代码github地址项目地址
新闻热点
疑难解答