Skip to content

Instantly share code, notes, and snippets.

@therne
Created February 15, 2014 02:35
Show Gist options
  • Select an option

  • Save therne/9013755 to your computer and use it in GitHub Desktop.

Select an option

Save therne/9013755 to your computer and use it in GitHub Desktop.
Rubbish XML Data...
<xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<!-- This is an title area -->
<LinearLayout android:layout_width="match_parent" android:layout_height="48dp" android:orientation="horizontal">
<TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center"
android:text="Google" android:textSize="18sp" android:textColor="#FFFFFF"
android:layout_marginLeft="8dp" android:layout_marginRight="16dp" />
<EditText android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/searchField" android:hint="Search Google" android:layout_weight="1.0" />
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/ic_search" android:onClick="onSearchButton" />
</LinearLayout>
<!-- Result area! -->
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent">
<WebView android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/searchResult" android:visibility="gone" />
<TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"
android:text="No Search Result" android:id="@+id/noResult" />
</FrameLayout>
</LinearLayout>
public void onSearchButton(View view) {
WebView searchResult = (WebView)findViewById(R.id.searchResult);
EditText searchField = (EditText)findViewById(R.id.searchField);
searchResult.setVisibility(visible);
searchResult.load("http://www.google.com/search?q=" + searchField.getText().toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment