简体   繁体   中英

How to add iframe into an activity using android studio (I want to add google calender from a website)

This is my iframe code :

<iframe src="https://www.google.com/calendar/embed?mode=WEEK&amp;height=600&amp;wkst=7&amp;bgcolor=%23FFFFFF&amp;src=diit.info_m7f27lakenu0t49fbe2aojn9rg@group.calendar.google.com&amp;color=%23865A5A&amp;ctz=Asia%2FDhaka" style=" border-width:0 " width="750" height="440" frameborder="0" scrolling="no"></iframe>`

Now I want to show this google calendar into my activity. Please let me know how can i do that.

Using WebVew I guess...? Or are you encountering any problems using it?

İf you want to show google calendar in your app. You have to use google calendar api. Here is the step by step education in google developers.

google calendar app


İf you want to show a web site in your app,you can use WebView.

enter code public class WebViewActivity extends AppCompatActivity {
private WebView mWebView;
private static final String urlTag = "url";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    String postUrl = intent.getStringExtra(urlTag);
    String title=intent.getStringExtra("title");
    mWebView = new WebView(this);
    mWebView.getSettings().setJavaScriptEnabled(true);

    final Activity activity = this;

    mWebView.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
        }
    });

    mWebView.loadUrl(postUrl);
    // setContentView(mWebView);

    // TODO:YUKLEME PROGRESS DENE
   mWebView.setWebViewClient(new WebViewClient() {
        ProgressDialog progressDialog = new ProgressDialog(WebViewActivity.this);

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            Log.e("I am  loading Here ", "Start");
            progressDialog.setTitle("Loading");
            progressDialog.setMessage("Please wait....");
            progressDialog.show();

        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.e("I am  loading Here ", "Override");
            view.loadUrl(url);
            return true;

        }

        @Override
        public void onPageFinished(WebView view, String url) {
            progressDialog.dismiss();
        }

    });
    setContentView(mWebView);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM