Created
September 29, 2011 18:45
-
-
Save christilden/1251558 to your computer and use it in GitHub Desktop.
res/layout/main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<WebView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/webview" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.androidweb; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.webkit.WebChromeClient; | |
import android.webkit.WebSettings; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
public class Welcome extends Activity { | |
final Activity activity = this; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
WebView webView = (WebView) findViewById(R.id.webview); | |
WebSettings webSettings = webView.getSettings(); | |
webSettings.setJavaScriptEnabled(true); | |
webView.setWebChromeClient(new WebChromeClient() { | |
@Override | |
public void onProgressChanged(WebView view, int progress) { | |
activity.setTitle("Loading..."); | |
activity.setProgress(progress * 100); | |
if (progress == 100) | |
activity.setTitle(R.string.app_name); | |
} | |
}); | |
webView.setWebViewClient(new WebViewClient() { | |
@Override | |
public void onReceivedError(WebView view, int errorCode, String description, | |
String failingUrl) { | |
// Handle the error | |
} | |
@Override | |
public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
view.loadUrl(url); | |
return true; | |
} | |
}); | |
webView.loadUrl("http://10.1.80.140:8080/timesheet"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment