package cn.android.browser;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.android.browser.HelpTabAct;
import cn.android.browser.HistoryBean;
import cn.android.browser.HttpData;
import cn.android.browser.SQLiteHelper;
import cn.android.browser.WriteFavoriteXml;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.ContextMenu.ContextMenuInfo;
import android.webkit.WebBackForwardList;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class Main extends Activity
{
private WebView mWebView = null;
final Activity context = this;
private SQLiteHelper mOpenHelper;
public static Cursor myCursor_one;
Intent directCall;
private WriteFavoriteXml writeXml = new WriteFavoriteXml();
private ImageButton btn = null;
private EditText edit = null;
private ImageButton forwardBtn = null;
private ImageButton backBtn = null;
private ListView list = null;
private Button go_back = null;
private ImageButton menuBtn = null;
private final static int HISTORY_ITEM = 0; //历史记录
private final static int HTTP_ITEM = 1; //关于
private final static int SHORTCUT_ITEM = 2; //快捷方式
private final static int ADD_FAVORITE = 3; //加入收藏夹
private final static int FAVORITE_ITEM = 4; //收藏夹
private final static int PREFERENCE_ITEM = 5; //帮助网页
private final static int EXIT_ITEM = 7; //退出
private String cur_url = "http://m.hao123.com";
private final String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
List<Map<String, Object>> history_data = new ArrayList<Map<String, Object>>();
List<HistoryBean> xml_data = new ArrayList<HistoryBean>();
String[] dialog_data = new String[]{};
public int selectId = 0;
SharedPreferences sp;
Drawable drawable;
private static String SAVE_KEY = "save-view";
public static Main instance;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.w("debug.onCreate","onCreate");
requestWindowFeature(Window.FEATURE_PROGRESS);//让进度条显示在标题栏上
mOpenHelper = new SQLiteHelper(this);
directCall = new Intent(Intent.ACTION_MAIN);//快捷方式
onInit();
instance = this;
if (savedInstanceState == null)
{
deleteTable();
}
else
{
Bundle map = savedInstanceState.getBundle(SAVE_KEY);
if (map != null)
{
restoreState(map);
}
}
}
private void onInit() {
setContentView(R.layout.main);
edit = (EditText)findViewById(R.id.edit_1);
mWebView = (WebView) findViewById(R.id.wv1);
btn = (ImageButton)findViewById(R.id.button_1);
forwardBtn = (ImageButton)findViewById(R.id.forward_btn);
backBtn = (ImageButton)findViewById(R.id.back_btn);
menuBtn = (ImageButton)findViewById(R.id.menu_btn);
btn.setOnClickListener( new Button.OnClickListener()
{
public void onClick( View v )
{
// TODO Auto-generated method stub
String str = edit.getText().toString();
if(str != "")
{
cur_url = str;
setTitle();
mWebView.loadUrl(str);
}
}
} );
forwardBtn.setOnClickListener( new Button.OnClickListener()
{
public void onClick( View v )
{
// TODO Auto-generated method stub
if(mWebView.canGoForward())
mWebView.goForward();
}
} );
backBtn.setOnClickListener( new Button.OnClickListener()
{
public void onClick( View v )
{
// TODO Auto-generated method stub
if(mWebView.canGoBack())
mWebView.goBack();
}
} );
menuBtn.setOnClickListener( new Button.OnClickListener()
{
public void onClick( View v )
{
context.openOptionsMenu();
}
} );
mWebView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
mWebView.loadUrl(url);
cur_url = url;
setTitle();
//insertTable(url,1,mWebView.getTitle());
return true;
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
//Activity和Webview根据加载程度决定进度条的进度大小
//当加载到100%的时候 进度条自动消失
context.setProgress(progress * 100);
if(progress>=100)
{
insertTable(cur_url,1,view.getTitle());
}
//Log.d("TTTTTTTTT",progress+","+view.getTitle());
}
});
mWebView.loadUrl(cur_url);
setTitle();
Log.i("debug.Init",cur_url);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
Log.i("onCreateContextMenu",v.toString());
Log.i("onCreateContextMenu",String.valueOf(v.getId()));
}
private void setTitle()
{
Bitmap bitmap = mWebView.getFavicon();
drawable = new BitmapDrawable(bitmap);
//edit.setCompoundDrawables(drawable, null, null, null);
drawable = this.getResources().getDrawable(R.drawable.history);
edit.setCompoundDrawablesWithIntrinsicBounds(drawable, null,null,null);
edit.setText(cur_url);
//edit.setMaxLines(1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0, HISTORY_ITEM, HISTORY_ITEM, R.string.history).setIcon(R.drawable.history); //setIcon,setText
menu.add(0, HTTP_ITEM, HTTP_ITEM, R.string.http_name).setIcon(R.drawable.about);
menu.add(0, SHORTCUT_ITEM, SHORTCUT_ITEM, R.string.shortcut).setIcon(R.drawable.icon);
menu.add(0, ADD_FAVORITE, ADD_FAVORITE, R.string.addFavorite).setIcon(R.drawable.add_favorite);
menu.add(0, FAVORITE_ITEM, FAVORITE_ITEM, R.string.favorite).setIcon(R.drawable.favorite);
menu.add(1, PREFERENCE_ITEM, PREFERENCE_ITEM, R.string.preference).setIcon(R.drawable.help);
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId()){
case HISTORY_ITEM:
goto_history_view();
break;
case HTTP_ITEM:
showDialog(HTTP_ITEM);
break;
case SHORTCUT_ITEM:
createShortcut();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 网页浏览器源码.zip项目安卓应用源码下载Android 网页浏览器源码.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源详情
资源评论
资源推荐
收起资源包目录
Android 网页浏览器源码.zip (90个子文件)
Android 网页浏览器源码
Android 网页浏览器源码
1_120819211339_2.png 40KB
1_120819211339_1.png 32KB
Android 网页浏览器源码
bin
classes.dex 42KB
cn
android
browser
Main$16.class 890B
Main$13.class 1KB
Main$7.class 737B
Main$2.class 906B
HttpData$2.class 971B
Main$10.class 2KB
R$layout.class 538B
Main$8.class 1KB
R$id.class 897B
R$drawable.class 739B
WebPreference.class 2KB
FavoriteXmlHandler.class 3KB
HelpTabAct$1.class 2KB
WriteFavoriteXml.class 6KB
HistoryBean.class 1KB
SQLiteHelper.class 2KB
R$attr.class 340B
HttpData$1.class 990B
R.class 669B
R$array.class 436B
Main.class 17KB
Main$17.class 801B
WebPreference$1.class 2KB
Main$1.class 1KB
Main$12.class 864B
Main$9.class 851B
HelpTabAct.class 3KB
R$string.class 978B
Main$3.class 900B
Main$15.class 820B
R$xml.class 392B
Main$4.class 807B
R$anim.class 508B
HttpData$ImageAdapter.class 2KB
HttpData.class 10KB
LongTextBox.class 2KB
Main$11.class 1KB
HelpTabAct$2.class 1019B
Main$5.class 978B
Main$6.class 1KB
Main$14.class 850B
resources.ap_ 44KB
MyBrowser.apk 67KB
res
drawable-ldpi
icon.png 3KB
drawable-hdpi
icon.png 9KB
drawable
history.PNG 898B
favorite.PNG 1KB
forward.PNG 635B
about.png 3KB
back.PNG 594B
go.PNG 1KB
icon.png 5KB
tab_indicator.xml 874B
add_favorite.PNG 969B
tab_focus.png 1KB
help.PNG 1KB
menu.PNG 537B
values
strings.xml 1004B
arrays.xml 326B
drawable-mdpi
icon.png 5KB
anim
push_right_out.xml 286B
push_left_in.xml 286B
push_right_in.xml 287B
push_left_out.xml 287B
layout
gall.xml 866B
history.xml 684B
help.xml 853B
main.xml 2KB
http.xml 438B
vlist.xml 880B
xml
preferences.xml 1KB
assets
default.properties 449B
gen
cn
android
browser
R.java 4KB
.settings
org.eclipse.core.resources.prefs 116B
org.eclipse.jdt.core.prefs 629B
src
cn
android
browser
HistoryBean.java 745B
WriteFavoriteXml.java 5KB
FavoriteXmlHandler.java 3KB
HttpData.java 11KB
HelpTabAct.java 3KB
WebPreference.java 4KB
Main.java 19KB
LongTextBox.java 1KB
SQLiteHelper.java 1KB
.project 845B
.classpath 280B
AndroidManifest.xml 1KB
共 90 条
- 1
yxkfw
- 粉丝: 81
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- bdwptqmxgj11.zip
- onnxruntime-win-x86
- onnxruntime-win-x64-gpu-1.20.1.zip
- vs2019 c++20 语法规范 头文件 <ratio> 的源码阅读与注释,处理分数的存储,加减乘除,以及大小比较等运算
- 首次尝试使用 Win,DirectX C++ 中的形状渲染套件.zip
- 预乘混合模式是一种用途广泛的三合一混合模式 它已经存在很长时间了,但似乎每隔几年就会被重新发现 该项目包括使用预乘 alpha 的描述,示例和工具 .zip
- 项目描述 DirectX 引擎支持版本 9、10、11 库 Microsoft SDK 功能相机视图、照明、加载网格、动画、蒙皮、层次结构界面、动画控制器、网格容器、碰撞系统 .zip
- 项目 wiki 文档中使用的代码教程的源代码库.zip
- 面向对象的通用GUI框架.zip
- 基于Java语言的PlayerBase游戏角色设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0