Java Code Examples for android.webkit.WebView#setId()

The following examples show how to use android.webkit.WebView#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebViewDialog.java    From cloudflare-scrape-Android with MIT License 6 votes vote down vote up
private void initWebView(){
    mWebView = new WebView(mContext);
    ConstraintLayout.LayoutParams layoutParams =
            new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
    mWebView.setLayoutParams(layoutParams);
    mWebView.setId(R.id.webview);
    mWebView.setVisibility(View.INVISIBLE);
    mLayout.addView(mWebView,-1);
    mAdvanceWebClient = new AdvanceWebClient(getContext(), mWebView,mUser_agent);
    mAdvanceWebClient.setListener(mLoginSuccessListener);
    mAdvanceWebClient.initWebView("https://" + mUrl.getHost());
}
 
Example 2
Source File: WebViewRelativeLayout.java    From userapp-android with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public WebViewRelativeLayout(Context context) {
       super(context);
       
       webView = new WebView(context);
       webView.setId(0X100);
       webView.setScrollContainer(true);
       
       RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
       params.addRule(RelativeLayout.CENTER_IN_PARENT);
       webView.setLayoutParams(params);
      
       WebSettings webSettings = webView.getSettings();
       webSettings.setJavaScriptEnabled(true);
       
       addView(webView);
   }
 
Example 3
Source File: QuestionnaireView.java    From QuestionnaireView with MIT License 4 votes vote down vote up
private void drawInnerViews(Context context, AttributeSet attrs){
    float density = context.getResources().getDisplayMetrics().density;
    int value16 = (int)(16*density);
    int value10 = (int)(10*density);
    int value40 = (int)(40*density);
    LayoutParams mainLayoutParams = new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mainLayoutParams.setMargins(value16,value16,value16,value16);
    setLayoutParams(mainLayoutParams);

    //creation & addition of webview
    webview = new WebView(context, attrs);
    webview.setId(android.R.id.content);
    webview.setLayoutParams(
            new LayoutBuilder()
                    .addWidth(LayoutParams.MATCH_PARENT)
                    .addHeight(LayoutParams.WRAP_CONTENT)
                    .setMargin(value10,value40,0,0)
                    .create()
    );
    webview.getSettings();
    webview.setBackgroundColor(Color.argb(0,0,0,0));
    addView(webview);

    //creation of list view
    listView = new ListView(context, attrs);
    listView.setId(android.R.id.list);
    listView.setLayoutParams(
            new LayoutBuilder()
                    .addWidth(LayoutParams.MATCH_PARENT)
                    .addHeight(LayoutParams.WRAP_CONTENT)
                    .setMargin(0,value10,0,0)
                    .addRule(BELOW, webview.getId() )
                    .create()
    );
    addView(listView );

    //creation & addition of editText
    editTv = new AppCompatEditText(context, attrs);
    editTv.setVisibility(GONE);
    editTv.setId(android.R.id.text1);
    editTv.setLayoutParams(
            new LayoutBuilder()
                    .addWidth(LayoutParams.MATCH_PARENT)
                    .addHeight(LayoutParams.WRAP_CONTENT)
                    .setMargin(value10, value10, 0, 0)
                    .addRule(BELOW, webview.getId())
                    .create()
    );
    editTv.setInputType(InputType.TYPE_CLASS_TEXT);
    editTv.setImeOptions(EditorInfo.IME_ACTION_DONE);
    addView(editTv );

}
 
Example 4
Source File: LightningView.java    From Xndroid with GNU General Public License v3.0 4 votes vote down vote up
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mWebView.setWebViewClient(new LightningWebClient(activity, this));
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}
 
Example 5
Source File: LightningView.java    From JumpGo with Mozilla Public License 2.0 4 votes vote down vote up
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mLightningWebClient = new LightningWebClient(activity, this);
    mWebView.setWebViewClient(mLightningWebClient);
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}