android 启动页面
来源:互联网 发布:华硕笔记本win10优化 编辑:程序博客网 时间:2024/06/05 10:47
一.文字启动
AndroidManifest.xml 启动app
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jihui88.myapplication"> <application android:allowBackup="true" android:icon="@drawable/ico" android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <activity android:name=".WelcomeActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"></activity> </application> <uses-permission android:name="android.permission.INTERNET" /></manifest>
activity_main.xml 主页面
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"/></RelativeLayout>
welcome.xml 欢迎页
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" tools:context=".MainActivity"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_centerInParent="true"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <ImageView android:id="@+id/jay_studio_icon" android:layout_width="150dip" android:layout_height="150dip" android:src="@drawable/ico"/> </RelativeLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <TextView android:id="@+id/app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="6dip" android:text="@string/app_name" android:textSize="24sp"/> <TextView android:id="@+id/version" android:layout_width="wrap_content" android:layout_height="fill_parent" android:gravity="bottom" android:paddingBottom="6dip" android:text="@string/version" android:textSize="14sp"/> </LinearLayout> <View android:layout_width="fill_parent" android:layout_height="1px" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:background="#dddddd"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:padding="6dip" android:text="建立企业自己的互联网销售平台" android:textSize="13sp"/> </LinearLayout> <TextView android:id="@+id/copy_right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dip" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:text="© 浙江机汇网络科技有限公司" android:textSize="11sp"/></RelativeLayout>
MainActivity.java
@SuppressLint("SetJavaScriptEnabled")public class MainActivity extends Activity { private WebView mWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.webview); mWebView.setWebViewClient(new WebViewClient()); // Enable Javascript 开启Javascript支持 mWebView.getSettings().setJavaScriptEnabled(true); // Use remote resource mWebView.loadUrl("http://m1.jihui88.com/#/"); } // Prevent the back-button from closing the app 连续点击两次Back键退出程序 long startTime = 0; @Override public void onBackPressed() { if(mWebView.canGoBack()) {//canGoBack来判断是否能回退网页 mWebView.goBack(); } else { long currentTime = System.currentTimeMillis(); if ((currentTime - startTime) >= 2000) { Toast.makeText(MainActivity.this, "再按一次退出", Toast.LENGTH_SHORT).show(); startTime = currentTime; } else { finish(); } //super.onBackPressed();//回调 } }}
WelcomeActivity.java
/** * @author wes * 功能描述:欢迎界面 */public class WelcomeActivity extends Activity implements Runnable{ //是否是第一次使用 private boolean isFirstUse; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome); /** * 启动一个延迟线程 */ new Thread(this).start(); } public void run() { try { /** * 延迟两秒时间 */ Thread.sleep(5000); //读取SharedPreferences中需要的数据 SharedPreferences preferences = getSharedPreferences("isFirstUse",MODE_WORLD_READABLE); isFirstUse = preferences.getBoolean("isFirstUse", true); /** *如果用户不是第一次使用则直接调转到显示界面,否则调转到引导界面 */ if (!isFirstUse) { startActivity(new Intent(WelcomeActivity.this, MainActivity.class)); } finish(); //实例化Editor对象 SharedPreferences.Editor editor = preferences.edit(); //存入数据 editor.putBoolean("isFirstUse", false); //提交修改 editor.commit(); } catch (InterruptedException e) { } }}
二.图片切换
问题
1.第次进入app 都会加载引导页
2.轮播功能未实现
3.加载时请求数据
0 0
- android应用启动页面
- Android启动页面整理
- android 启动页面
- Android APP启动页面
- Android启动页面制作
- Android应用启动页面
- android 启动页面
- android 启动页面
- android启动页面
- android 启动页面
- Android启动页面
- android启动页面制作
- Android 启动activity 空白页面
- android应用启动页面显示
- Android 代码启动activity页面
- Android启动页面设置Splash
- Android 启动页面弹出效果
- android 启动页面的设置
- 51单片机使用蜂鸣器
- Windows编程学习笔记 lesson2 窗口创建
- 电脑网正常,除了IE之外其他浏览器都能正常上网,IE不能上网解决办法
- xib:*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x1
- Java集合框架的理解
- android 启动页面
- SQL Server 2005 常用数据类型详解
- 网站架构-参考文章
- iOS-通俗易懂的微信支付接入和爬坑指南,十分钟轻松搞完
- c#——字典转化为对象(dictionary to object)
- 深入理解Java的接口和抽象类
- java集合框架
- 根据一个包含汉字的字符串返回一个汉字拼音首字母的字符串
- 一次混杂程序跑在一台机器上的内存排查 (1)