Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetLayoutParamssetWebChromeClientsetWebViewClient, setId

0
        AbsoluteLayout layout = new AbsoluteLayout(this);
        //layout.setOrientation(LinearLayout.VERTICAL); 
        setContentView(layout);
        oV = layout;
 
        WebView wv = new WebView(this);
        wv.setWebViewClient(new WebViewClient() {});
        wv.getSettings().setJavaScriptEnabled(true);
 
        wv.setWebViewClient(new TkFoxClient());
 
 
        WebChromeClient chromeClient = new WebChromeClient(){
        	@Override 
            public void onShowCustomView(View view, CustomViewCallback callback) {
                // TODO Auto-generated method stub 
 
                ViewGroup mainFrame = (ViewGroup)findViewById(R.id.mitorizubase);
                Log.i("onSS", "in");
                //mainFrame.addView(view); 
 
                setContentView(view);
                nV = true;
                Log.i("nV trace", "SET");
                customViewCallback = callback;
                //customView = view; 
 
                //View browserFrame = findViewById(R.id.browserFrame); 
                //mainFrame.setVisibility(View.GONE); 
 
                //Log.i("test",wv.getUrl().toString()); 
                //if(view instanceof FrameLayout){ 
                //    FrameLayout frame  = (FrameLayout)view; 
                //    if(frame.getFocusedChild()instanceof VideoView){ 
                //    VideoView video =  (VideoView)frame.getFocusedChild(); 
                //        frame.removeView(video); 
                //        video.start(); 
                //    } 
                //} 
                super.onShowCustomView(view, callback);
            } 
        }; 
 
        wv.setWebChromeClient(chromeClient);
 
        //wv.loadUrl("file:///android_asset/index.html"); 
        //wv.loadUrl("https://dl.dropbox.com/u/88219936/index.html"); 
        wv.setLayoutParams(new AbsoluteLayout.LayoutParams((int)sx, (int)sy, 0, 0));
        wv.setId(5);
        layout.addView(wv);
 
 
        //Button btn = new Button(this); 
        //int ti = 5; 
        //btn.setLayoutParams(new AbsoluteLayout.LayoutParams(dx*6, dy*1, dx, dy*ti)); 
        //btn.setText("動的に作成したボタン"); 
        //ClickListener listener = new ClickListener(); 
        //btn.setOnClickListener(listener); 
        //btn.setId(1); 
        //layout.addView(btn); 
 
        bw = (int)(sy * 7 / 60);
        tt = (int)(sy * 1 / 30);
        bt = (int)(sy * 51 / 60);
        ll = (int)(sx - (sy * 3 / 10));
        rl = (int)(sx - (sy * 3 / 20));
        bzt = (int)(sy * 49 / 60);
        bzh = (int)(sy * 12 / 60);
 
        ClickListener listener = new ClickListener();
 
        ImageView basez = new ImageView(this);
        basez.setLayoutParams(new AbsoluteLayout.LayoutParams(0, 0, 0, 0));
        basez.setBackgroundColor(Color.argb(255, 0, 0, 255));
        basez.setId(4);
        layout.addView(basez);
 
        ImageView btn01 = new ImageView(this);
        btn01.setLayoutParams(new AbsoluteLayout.LayoutParams(bw, bw, ll, tt));
        btn01.setImageResource(drawable.bt_map);
        btn01.setId(1);
        btn01.setOnClickListener(listener);
        layout.addView(btn01);
 
        ImageView btn02 = new ImageView(this);
        btn02.setLayoutParams(new AbsoluteLayout.LayoutParams(bw, bw, rl, tt));
        btn02.setImageResource(drawable.bt_scan);
        btn02.setId(2);
        btn02.setOnClickListener(listener);
        layout.addView(btn02);
 
        ImageView btn03 = new ImageView(this);
        btn03.setLayoutParams(new AbsoluteLayout.LayoutParams(0, 0, 0, 0));
        btn03.setImageResource(drawable.bt_back);
        btn03.setId(3);
        btn03.setOnClickListener(listener);
        layout.addView(btn03);
 
 
        UserSession objUser = UserSession.getInstance();
        String doURL = objUser.getdoURL();
 
        //wv.loadUrl("http://fhaku.orchestra.io/fn01a001.html"); 
        wv.loadUrl(doURL);
        //setContentView(R.layout.main); 
    } 
 
    public class TkFoxClient extends WebViewClient {
        @Override 
Stop searching for code, let great code find you!  Add Codota to your java IDE