Skip to content

Instantly share code, notes, and snippets.

[[Dog giveMeAnimalC] makeSound];
[[Dog giveMeAnimalB] makeSound];
@implementation Animal
+ (id)giveMeAnimalA {
return [[[self class] alloc] init];
}
+ (instancetype)giveMeAnimalB {
return [[[self class] alloc] init];
}
public class Person {
private String name;
private String address;
public Person(String name, String address) {
this.name = name;
this.address = address;
}
public String getName() {
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView = (ListView)findViewById(R.id.listView);
Person john = new Person("John", "123 Fake Dr.");
public class PersonAdapter extends BaseAdapter {
private ArrayList<Object> personArray;
private LayoutInflater inflater;
private static final int TYPE_PERSON = 0;
private static final int TYPE_DIVIDER = 1;
public PersonAdapter(Context context, ArrayList<Object> personArray) {
this.personArray = personArray;
this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
<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"
tools:context=".MainActivity">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/nameLabel"
android:layout_width="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@android:color/darker_gray"
>
<TextView
android:id="@+id/headerTitle"
android:layout_width="wrap_content"
@rajohns08
rajohns08 / ViewController.swift
Last active November 3, 2015 13:22
iOS / Swift - Put a max number of characters for UITextField
import UIKit
let maxNumCharacters = 5
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}