android.webkit.WebView.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(284)

本文整理了Java中android.webkit.WebView.<init>()方法的一些代码示例,展示了WebView.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.<init>()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:<init>

WebView.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

WebView webview = new WebView(this);      
webview.setWebViewClient(new WebViewClient() {  
  @Override  
  public boolean shouldOverrideUrlLoading(WebView view, String url)  
  {  
   view.loadUrl(url); //this is controversial - see comments and other answers
   return true;  
  }  
 });                 
setContentView(webview);      
webview.loadUrl([MY URL]);

代码示例来源:origin: stackoverflow.com

WebView webView = new WebView();
URI uri = URI.create("http://mysite.com");
Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>();
headers.put("Set-Cookie", Arrays.asList("name=value"));
java.net.CookieHandler.getDefault().put(uri, headers);
webView.getEngine().load("http://mysite.com");

代码示例来源:origin: stackoverflow.com

public class MyPdfViewActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  WebView mWebView=new WebView(MyPdfViewActivity.this);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.getSettings().setPluginsEnabled(true);
  mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
  setContentView(mWebView);
 }
}

代码示例来源:origin: stackoverflow.com

JFXPanel jfxPanel = new JFXPanel(); // Scrollable JCompenent
Platform.runLater( () -> { // FX components need to be managed by JavaFX
  WebView webView = new WebView();
  webView.getEngine().loadContent( "<html> Hello World!" );
  webView.getEngine().load( "http://www.stackoverflow.com/" );
  jfxPanel.setScene( new Scene( webView ) );
});

代码示例来源:origin: stackoverflow.com

WebView view = new WebView(this);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl("file:///android_asset/hello.html");
setContentView(view);

代码示例来源:origin: stackoverflow.com

fxPanel.setScene(scene);
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load("http://www.google.com/");

代码示例来源:origin: stackoverflow.com

WebView webview = new WebView();
webview.setWebViewClient(new WebClient());
webView.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("stackoverflow.com");

代码示例来源:origin: stackoverflow.com

@Override public void run() {
  WebView view = new WebView();
  engine = view.getEngine();

代码示例来源:origin: stackoverflow.com

mWebview  = new WebView(this);
mWebview .loadUrl("http://www.google.com");
setContentView(mWebview );

代码示例来源:origin: stackoverflow.com

File f = new File(..);
// ..
final WebView webview = new WebView();
webview.getEngine().load(f.toURI().toURL().toString());

代码示例来源:origin: stackoverflow.com

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("Title here");

WebView wv = new WebView(this);
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient() {
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);

    return true;
  }
});

alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
  @Override
  public void onClick(DialogInterface dialog, int id) {
    dialog.dismiss();
  }
});
alert.show();

代码示例来源:origin: stackoverflow.com

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebViewVersion extends Application {
  @Override public void start(Stage stage) {
    WebView web = new WebView();
    System.out.println(
        "Java Version:   " + System.getProperty("java.runtime.version")
    );
    System.out.println(
        "JavaFX Version: " + System.getProperty("javafx.runtime.version"
    );
    System.out.println(
        "OS:             " + System.getProperty("os.name") + ", " 
                  + System.getProperty("os.arch")
    );
    System.out.println(
        "User Agent:     " + web.getEngine().getUserAgent()
    );
    Platform.exit();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

代码示例来源:origin: stackoverflow.com

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

LinearLayout wrapper = new LinearLayout(this);
WebView webView = new WebView(this);
EditText keyboardHack = new EditText(this);

keyboardHack.setVisibility(View.GONE);

webView.loadUrl(url);

wrapper.setOrientation(LinearLayout.VERTICAL);
wrapper.addView(webView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
wrapper.addView(keyboardHack, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);              

builder.setView(wrapper);

builder.create().show();

代码示例来源:origin: stackoverflow.com

public void start(Stage primaryStage) {
  WebView webview = new WebView();
  final WebEngine webengine = webview.getEngine();
  webengine.getLoadWorker().stateProperty().addListener(
      new ChangeListener<State>() {
        public void changed(ObservableValue ov, State oldState, State newState) {
          if (newState == Worker.State.SUCCEEDED) {
            Document doc = webengine.getDocument();
            try {
              Transformer transformer = TransformerFactory.newInstance().newTransformer();
              transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
              transformer.setOutputProperty(OutputKeys.METHOD, "xml");
              transformer.setOutputProperty(OutputKeys.INDENT, "yes");
              transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
              transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

              transformer.transform(new DOMSource(doc),
                  new StreamResult(new OutputStreamWriter(System.out, "UTF-8")));
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        }
      });
  webengine.load("http://stackoverflow.com");
  primaryStage.setScene(new Scene(webview, 800, 800));
  primaryStage.show();
}

代码示例来源:origin: stackoverflow.com

public class ServiceWithWebView extends Service {

  @Override
  public void onCreate() {
    super.onCreate();

    WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.x = 0;
    params.y = 0;
    params.width = 0;
    params.height = 0;

    LinearLayout view = new LinearLayout(this);
    view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));

    WebView wv = new WebView(this);
    wv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    view.addView(wv);
    wv.loadUrl("http://google.com");

    windowManager.addView(view, params);
  }
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) { launch(args); }
@Override public void start(Stage primaryStage) {
 final WebView webView = new WebView();
 final WebEngine engine = webView.getEngine();
 engine.load("http://docs.oracle.com/javafx/2/get_started/animation.htm");
 engine.documentProperty().addListener(new ChangeListener<Document>() {

代码示例来源:origin: seven332/EhViewer

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mWebView = new WebView(this);
  mWebView.loadUrl("file:///android_asset/NOTICE.html");
  setContentView(mWebView);
  setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
}

代码示例来源:origin: stackoverflow.com

final WebView webview  = new WebView();
  createProgressReport(webview.getEngine()),
  webview
);
stage.show();
webview.getEngine().load("http://www.fxexperience.com");

代码示例来源:origin: commonsguy/cw-omnibus

@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  WebView wv=new WebView(getContext());
  wv.loadUrl("https://commonsware.com");
  setContentView(wv);
 }
}

代码示例来源:origin: stackoverflow.com

first = true;
final WebView view = new WebView();
view.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {

  @Override
  public void changed(ObservableValue<? extends Worker.State> ov, Worker.State t, Worker.State t1) {
    System.out.println(t1);
    if(t1.equals(State.SUCCEEDED) && first) {
      first = false;
      view.getEngine().reload();
    }
  }
});

相关文章

WebView类方法