Skip to content

Instantly share code, notes, and snippets.

View leonguyen's full-sized avatar

Nam Nguyen leonguyen

View GitHub Profile
@leonguyen
leonguyen / gist:5353961
Created April 10, 2013 11:49
Android Lab: Alert Dialog - Create Alert Dialog program
package com.example.androidlab;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
@leonguyen
leonguyen / gist:5402754
Created April 17, 2013 08:36
Android Lab: Shared References - Defining Main XML Layout
<?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="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editTextName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@leonguyen
leonguyen / gist:5402780
Created April 17, 2013 08:41
Android Lab: Shared References - Write a MainActivity program
package com.example.androidlab;
import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
@leonguyen
leonguyen / gist:5409423
Created April 18, 2013 02:07
Android Lab: Shared References - Reference Activity - Defining Main XML Menu
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menuSetting"
android:title="Setting"/>
</menu>
@leonguyen
leonguyen / gist:5409597
Last active December 16, 2015 08:59
Android Lab: Shared References - Reference Activity - Defining Preference XML
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Store" >
<ListPreference
android:entries="@array/listStore"
android:entryValues="@array/listStoreReturn"
android:key="prefStore"
android:title="Where do you want to store?" />
</PreferenceCategory>
@leonguyen
leonguyen / gist:5409613
Last active December 16, 2015 08:59
Android Lab: Shared References - Reference Activity - Create PreferenceActivity
package com.example.androidlab;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class SettingActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
@leonguyen
leonguyen / gist:5409836
Created April 18, 2013 03:26
Android Lab: Shared References - Reference Activity - Defining Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidlab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
@leonguyen
leonguyen / gist:5409973
Last active December 16, 2015 08:59
Android Lab: Shared References - Reference Activity - Defining Array XML Value
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="listStore">
<item>Internal Storage</item>
<item>External Storage</item>
</string-array>
<string-array name="listStoreReturn">
<item>Internal Storage has been set!</item>
<item>External Storage has been set!</item>
@leonguyen
leonguyen / gist:5410070
Created April 18, 2013 04:14
Android Lab: Shared References - Reference Activity - Write MainActivity program
package com.example.androidlab;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
@leonguyen
leonguyen / gist:5425418
Last active December 16, 2015 11:09
Android Lab: SQLite - Create User Entity class
package com.example.androidlab;
public class User {
// private variables
int id;
String name;
// Empty constructor
public User() {
}