Skip to content

Instantly share code, notes, and snippets.

View csdear's full-sized avatar

Stuart Dear csdear

View GitHub Profile
@csdear
csdear / Views : TextView
Created March 5, 2014 21:05
Views : TextViews
//Some exmaple view imports
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;
import android.widget.TextView;
//Creating textview fields
private static TextView dateView;
@csdear
csdear / View : ListView
Created March 5, 2014 21:17
Views : ListView ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Creating an adapter to populate the listview
mAdapter = new ToDoListAdapter(getApplicationContext());
// Put divider between ToDoItems and FooterView
@csdear
csdear / Fragments
Created March 5, 2014 22:12
Fragments
import android.app.FragmentManager;
import android.app.FragmentTransaction
private FragmentManager mFragmentManager;
private FriendsFragment mFriendsFragment;
//onCreate
mFragmentManager = getFragmentManager();
@csdear
csdear / Parse JSON
Created March 5, 2014 22:16
parseJSON
private String[] mRawFeeds = new String[3];
private String[] mProcessedFeeds = new String[3];
private static final int NUM_FRIENDS = 3;
=======================
// Called when new Tweets have been downloaded
public void setRefreshed(String[] feeds) {
mRawFeeds[0] = feeds[0];
mRawFeeds[1] = feeds[1];
@csdear
csdear / SelectionListener Interface
Created March 5, 2014 22:23
SelectionListener Public Listener
package course.labs.notificationslab;
public interface SelectionListener {
public void onItemSelected(int position);
}
//Supporting Fragment class1
//field
private SelectionListener mCallback;
@csdear
csdear / Drawable : Programmatic
Created March 6, 2014 16:53
Drawable : Programmatic
package <<packageName>>;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import course.examples.Graphics.Bubble.R;
public class <<activityName>> extends Activity {
@csdear
csdear / Drawable : Simple XML
Created March 6, 2014 16:58
Drawable : Simple ShapeDrawable XML
package course.examples.Graphics.ShapeDrawXML;
import android.app.Activity;
import android.os.Bundle;
public class ShapeDrawActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
@csdear
csdear / Shape Drawables : Programmatic
Created March 6, 2014 22:47
Shape Drawables : Programmatic Demo : Creating shapes ovals to display in a empty relative layout view container.
//ShapeDrawACtivity.java
package course.examples.Graphics.ShapeDraw;
//1. Imports
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Bundle;
@csdear
csdear / Drawable : Canvas. Simple
Created March 6, 2014 23:18
Drawable : Canvas Simple shapes Style configuration of the textviews in main.xml each point to a shape xml file.
//main.xml contains the textviews whose drawable reference SQ shape xml files.
<?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:background="#FFCCCCCC"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
@csdear
csdear / WebView with Progress Loader
Created March 11, 2014 20:05
A WebView with Progress Bar / Loader An activity that implements the webViewCLient in the onActivityCreated method A loader layout to contain the webview Reference : http://developer.android.com/reference/android/webkit/WebView.html See example in X: Code Repo >> UI >> Webviews Permission to access the internet. Components ViewFragments for the …
//1. The xml layout file
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/<<webView>>">
</WebView>
===================