当前位置:编程学习 > wap >>

Android简单app开发问题请教

我只是想制作一个app,这个应用只需可以转到指定的网站上。意思就是,打开它可以转到网页即可。请与详细说明。 --------------------编程问答--------------------

package com.fansoft.test;

import com.fansoft.mgs.*;
import java.io.File;
import java.io.FileFilter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils.TruncateAt;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class PlayFlash extends Activity implements OnClickListener 
{
        WebView FlashView, FlashView2;
        String filename, filename2;
    Button Flash, Flash2, Flash3;

public void onCreate(Bundle savedInstanceState) 
{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.play_flash);

        Flash= (Button) findViewById(R.id.ID_PSWF_Flash);
        Flash.setOnClickListener(this);
        Flash2= (Button) findViewById(R.id.ID_PSWF_Flash2);
        Flash2.setOnClickListener(this);
        Flash3= (Button) findViewById(R.id.ID_PSWF_Flash3);
        Flash3.setOnClickListener(this);
        
        FlashView = (WebView) findViewById(R.id.ID_PSWF_webView);
        FlashView.getSettings().setPluginState( PluginState.ON );
        FlashView.setBackgroundColor( 0); 
//      FlashView.getSettings().setPluginsEnabled(true);

        FlashView2 = (WebView) findViewById(R.id.ID_PSWF_webView2);
        FlashView2.getSettings().setPluginState( PluginState.ON );
        FlashView2.setBackgroundColor( Color.GREEN);
//      FlashView2.getSettings().setPluginsEnabled(true);

        //      FlashView.loadUrl("http://www.baidu.com");
        
//      filename = "file://"+Mgs.GetSDCardPath()+"/Arrow.swf";
//Log.e("Flash", filename);
//      FlashView.loadUrl( filename);
}

public  void onClick(View V)
{
//      final LinearLayout layout=(LinearLayout)findViewById(R.id.ID_DBoxMain);
        switch(V.getId())
        {
        case R.id.ID_PSWF_Flash:
                filename = "file://"+Mgs.GetSDCardPath()+"/fanclt.pipe.swf";
                Log.e("Flash", filename);
                FlashView.loadUrl( filename);
                filename2= "file://"+Mgs.GetSDCardPath()+"/fanclt.phone.swf";
//              filename2= "file://www.fansoft.cn/image/swf/fanclt.phone.swf";
                Log.e("Flash", filename2);
                FlashView2.loadUrl( filename2);
                break;
        case R.id.ID_PSWF_Flash2:
                filename = "http://www.fansoft.cn/mob.php";
                Log.e("Flash", filename);
                FlashView.loadUrl( filename);
                break;
        case R.id.ID_PSWF_Flash3:
                filename = "http://www.fansoft.cn/adv/adv.fansel.net.android.php";
                Log.e("Flash", filename);
                FlashView.loadUrl( filename);
                break;        }
}
}
自己看,用WebView很容易实现的.
点左上角按钮和左下角按钮就是进入网址, 这是我当时做练习用的. --------------------编程问答-------------------- 不好意思的, 2个图片顺序 弄反了, 先是第二个, 点击按钮后,才是地1 个图, 呵呵.
这个网站址 不如www.apkbus.com安卓论坛好, 它的图片是直接显示的,不会弄错.
--------------------编程问答--------------------

Intent intent = new Intent();
intent.setData(Uri.parse(sUrl));
intent.setAction(Intent.ACTION_VIEW);
this.startActivity(intent); //启动浏览器


sUrl 就是你要打开的网址
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,