NoteBrowser Source Code
NoteBrowser Source Code is here.
Download the full project file here.
GitHub https://github.com/stingraze/NoteBrowser
NoteBrowserActivity.java
package tsubasakato.com.notebrowser; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; public class NoteBrowserActivity extends Activity { private EditText editText; private Button button; private SharedPreferences pref; /** Called when the activity is first created. */ private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } EditText URLText; Button GoButton; WebView Browser; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); URLText = (EditText)findViewById(R.id.URL); GoButton = (Button)findViewById(R.id.Go); Browser = (WebView) findViewById(R.id.WebEngine); Browser.loadUrl("http://www.google.com/"); Browser.setWebViewClient(new WebViewClient()); Browser.requestFocus(View.FOCUS_DOWN); Browser.getSettings().setJavaScriptEnabled(true); Browser.getSettings().setBuiltInZoomControls(true); GoButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Browser.setWebViewClient(new MyWebViewClient()); Browser.loadUrl("http://"+URLText.getText().toString()); Browser.requestFocus(View.FOCUS_DOWN); } }); editText = (EditText) findViewById(R.id.editText1); pref = getPreferences(MODE_PRIVATE); editText.setText(pref.getString("test", "")); button = (Button) findViewById(R.id.save); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Editor editor = pref.edit(); editor.putString("test", editText.getText().toString()); editor.commit(); Toast.makeText(getApplicationContext(), "Note Saved.", Toast.LENGTH_SHORT).show(); } }); } }
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <EditText android:id="@+id/URL" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ems="10" android:text="www.google.com" /> <Button android:id="@+id/Go" android:layout_width="fill_parent" android:layout_height="35dp" android:text="Go" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TableRow> <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TableRow> </TableLayout> <WebView android:id="@+id/WebEngine" android:layout_width="fill_parent" android:layout_height="200px" /> <EditText android:id="@+id/editText1" android:layout_width="fill_parent" android:layout_height="88dp" android:ems="10" android:inputType="textMultiLine" /> <Button android:id="@+id/save" android:layout_width="122dp" android:layout_height="wrap_content" android:text="Save Note" /> </LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tsubasakato.com.notebrowser" android:versionCode="4" android:versionName="1.4" > <uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".NoteBrowserActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>