0818b9ca8b590ca3270a3433284dd417.png

取消屏幕标题,软件最大化.

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

实例化WEBVIEW空间之后

设置控件增大缩小。

加载html文件file:///android_asset/index.htm,文件位置放在assets中

mWebView.getSettings().setBuiltInZoomControls(true);

mWebView.loadUrl("file:///android_asset/index.htm");

---------------------------------------

-----------------主ACTIVITY

package tangshi.co.cc;

import net.miidi.credit.MiidiCredit;

import android.app.Activity;

import android.app.AlertDialog;

import android.app.AlertDialog.Builder;

import android.content.DialogInterface;

import android.content.Intent;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.SubMenu;

import android.view.Window;

import android.view.WindowManager;

import android.webkit.WebView;

public class HahamxActivity extends Activity {

private WebView webView;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

MiidiCredit

.init(HahamxActivity.this, "4573", "h3mj1k5b5lwopknk", false);

setContentView(R.layout.main);

// webView = (WebView) findViewById(R.id.webview1);

// ProxyBridge pBridge = new ProxyBridge();

// webView.addJavascriptInterface(pBridge, "AliansBridge");

// WebSettings wSet = webView.getSettings();

// wSet.setJavaScriptEnabled(true);

// webView.loadUrl("file:///android_asset/naojing.htm");

// TextView mTextView=(TextView)findViewById(R.id.webview1);

WebView mWebView = (WebView) findViewById(R.id.webview1);

mWebView.getSettings().setBuiltInZoomControls(true);

mWebView.loadUrl("file:///android_asset/index.htm");

}

protected void dialog() {

AlertDialog.Builder builder = new Builder(HahamxActivity.this);

builder.setTitle("唐诗宋词元曲");

builder.setMessage("你真的要退出唐诗宋词元曲吗?");

builder.setPositiveButton("否",

new android.content.DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

dialog.dismiss();

}

});

builder.setNegativeButton("是",

new android.content.DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

dialog.dismiss();

android.os.Process.killProcess(android.os.Process

.myPid());

}

});

builder.create().show();

}

public void onBackPressed() {

dialog();

}

public boolean onCreateOptionsMenu(Menu menu) {

// TODO Auto-generated method stub

SubMenu subMenu2 = menu.addSubMenu(0, 2, 0, "唐诗三百首");

SubMenu subMenu3 = menu.addSubMenu(0, 3, 0, "宋词");

SubMenu subMenu4 = menu.addSubMenu(0, 4, 0, "元曲");

// SubMenu subMenu5 = menu.addSubMenu(0, 5, 0, "英文谚语");

SubMenu subMenu = menu.addSubMenu(0, 6, 0, "软件简介");

return super.onCreateOptionsMenu(menu);

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// TODO Auto-generated method stub

switch (item.getItemId()) {

case 6:

AlertDialog.Builder builder = new Builder(HahamxActivity.this);

builder.setTitle("唐诗宋词元曲!");

builder.setMessage(R.string.about);

builder.setPositiveButton("确定",

new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

// TODO Auto-generated method stub

}

});

builder.create().show();

break;

case 3:

Intent intent = new Intent(HahamxActivity.this, xiaohua3.class);

startActivity(intent);

break;

case 2:

Intent intent1 = new Intent(HahamxActivity.this, xiaohua.class);

startActivity(intent1);

break;

case 4:

Intent intent4 = new Intent(HahamxActivity.this, chunjie.class);

startActivity(intent4);

break;

// case 5:

// Intent intent5 = new Intent(HahamxActivity.this, yanyu.class);

// startActivity(intent5);

// break;

default:

break;

}

return super.onOptionsItemSelected(item);

}

public class ProxyBridge {

public int one() {

return 1;

}

}

}

---------------------接下来的ACTIVITY 类似创建

package tangshi.co.cc;

import tangshi.co.cc.R;

import android.app.Activity;

import android.os.Bundle;

import android.webkit.WebView;

public class chunjie extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.main4);

WebView mWebView4=(WebView)findViewById(R.id.webview4);

mWebView4.loadUrl("file:///android_asset/index4.htm");

mWebView4.getSettings().setBuiltInZoomControls(true);

}

}

--------------Splash动画

package tangshi.co.cc;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

public class Splash extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState)

{

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.splash);

new Handler().postDelayed(new Runnable()

{

@Override

public void run()

{

// TODO Auto-generated method stub

Intent it = new Intent(Splash.this, HahamxActivity.class);

startActivity(it);

finish();

}

}, 3000);

}

}

----------------main.xml 布局

xmlns:umadsdk="http://schemas.android.com/apk/res/tangshi.co.cc"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

xmlns:umadsdk="http://schemas.android.com/apk/res/tangshi.co.cc"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_marginTop="20px"

android:orientation="vertical" >

android:id="@+id/adView"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

umadsdk:backgroundColor="#4076AA"

umadsdk:backgroundTransparent="255"

umadsdk:textColor="#ffffff" >

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#FFFFFF"

android:orientation="vertical" >

android:id="@+id/imageView1"

android:layout_width="300px"

android:layout_height="180px"

android:layout_gravity="center"

android:src="@drawable/icon1" >

android:id="@+id/webview1"

android:layout_width="wrap_content"

android:layout_height="wrap_content" >

------------------------ 小程序仅供学习参考,祝大家学习愉快!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐