I'm trying to place a button over a webview, and I found the easiest way to do it is through xml. My MainActivity onCreate looks as such:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button buttonClick = (Button)findViewById(R.id.playButton);
mWebview = (WebView)findViewById(R.id.webview);
mWebview.getSettings().setJavaScriptEnabled(true); // enables javascript
System.out.println("Loading Webpage...");
new tts().execute("");
mWebview.loadUrl("http://www.aljazeera.com/news/americas/2013/07/20137113200544375.html");
mWebview.addView(buttonClick);
setContentView(mWebview);
}
My xml looks like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Pause" />
</RelativeLayout>
For some reason I'm getting a fatal error with a null pointer exception. Anyone have any insight as to why this is happening?