forked from Macarse/50AH-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hack030</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
Copyright (c) 2012 Manning | ||
See the file license.txt for copying permission. | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.manning.androidhacks.hack030" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk android:minSdkVersion="4" /> | ||
|
||
<application | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" > | ||
<activity android:name=".MainActivity" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system edit | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
# | ||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
||
# Project target. | ||
target=android-4 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
Copyright (c) 2012 Manning | ||
See the file license.txt for copying permission. | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="vertical" > | ||
|
||
<Button | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:onClick="onPickCountryClick" | ||
android:text="@string/activity_main_add_selection" /> | ||
|
||
<ListView | ||
android:id="@+id/activity_main_list" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:choiceMode="singleChoice" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!-- | ||
Copyright (c) 2012 Manning | ||
See the file license.txt for copying permission. | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" > | ||
|
||
<TextView | ||
android:id="@+id/country_view_title" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="0.9" | ||
android:padding="10dp" /> | ||
|
||
<CheckBox | ||
android:id="@+id/country_view_checkbox" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="0.1" | ||
android:clickable="false" | ||
android:focusable="false" | ||
android:focusableInTouchMode="false" | ||
android:gravity="center_vertical" | ||
android:padding="10dp" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- | ||
Copyright (c) 2012 Manning | ||
See the file license.txt for copying permission. | ||
--> | ||
<resources> | ||
|
||
<string name="app_name">Hack030</string> | ||
<string name="activity_main_toast_fmt">Picked Country: %s</string> | ||
<string name="activity_main_add_selection">Pick Country</string> | ||
</resources> |
66 changes: 66 additions & 0 deletions
66
hack030/src/com/manning/androidhacks/hack030/Countries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 Manning | ||
* See the file license.txt for copying permission. | ||
******************************************************************************/ | ||
package com.manning.androidhacks.hack030; | ||
|
||
public class Countries { | ||
public static final String[] COUNTRIES = new String[] { | ||
"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", | ||
"Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", | ||
"Argentina", "Armenia", "Aruba", "Australia", "Austria", | ||
"Azerbaijan", "Bahrain", "Bangladesh", "Barbados", "Belarus", | ||
"Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", | ||
"Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", | ||
"British Indian Ocean Territory", "British Virgin Islands", | ||
"Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cote d'Ivoire", | ||
"Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", | ||
"Central African Republic", "Chad", "Chile", "China", | ||
"Christmas Island", "Cocos (Keeling) Islands", "Colombia", | ||
"Comoros", "Congo", "Cook Islands", "Costa Rica", "Croatia", | ||
"Cuba", "Cyprus", "Czech Republic", | ||
"Democratic Republic of the Congo", "Denmark", "Djibouti", | ||
"Dominica", "Dominican Republic", "East Timor", "Ecuador", | ||
"Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", | ||
"Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", | ||
"Fiji", "Finland", "Former Yugoslav Republic of Macedonia", | ||
"France", "French Guiana", "French Polynesia", | ||
"French Southern Territories", "Gabon", "Georgia", "Germany", | ||
"Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", | ||
"Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", | ||
"Guyana", "Haiti", "Heard Island and McDonald Islands", | ||
"Honduras", "Hong Kong", "Hungary", "Iceland", "India", | ||
"Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", | ||
"Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", | ||
"Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", | ||
"Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", | ||
"Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", | ||
"Malta", "Marshall Islands", "Martinique", "Mauritania", | ||
"Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", | ||
"Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", | ||
"Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", | ||
"Netherlands Antilles", "New Caledonia", "New Zealand", | ||
"Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", | ||
"North Korea", "Northern Marianas", "Norway", "Oman", "Pakistan", | ||
"Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", | ||
"Philippines", "Pitcairn Islands", "Poland", "Portugal", | ||
"Puerto Rico", "Qatar", "Reunion", "Romania", "Russia", "Rwanda", | ||
"Sqo Tome and Principe", "Saint Helena", "Saint Kitts and Nevis", | ||
"Saint Lucia", "Saint Pierre and Miquelon", | ||
"Saint Vincent and the Grenadines", "Samoa", "San Marino", | ||
"Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", | ||
"Singapore", "Slovakia", "Slovenia", "Solomon Islands", | ||
"Somalia", "South Africa", | ||
"South Georgia and the South Sandwich Islands", "South Korea", | ||
"Spain", "Sri Lanka", "Sudan", "Suriname", | ||
"Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", | ||
"Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", | ||
"The Bahamas", "The Gambia", "Togo", "Tokelau", "Tonga", | ||
"Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", | ||
"Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", | ||
"Ukraine", "United Arab Emirates", "United Kingdom", | ||
"United States", "United States Minor Outlying Islands", | ||
"Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", | ||
"Vietnam", "Wallis and Futuna", "Western Sahara", "Yemen", | ||
"Yugoslavia", "Zambia", "Zimbabwe" }; | ||
} |
56 changes: 56 additions & 0 deletions
56
hack030/src/com/manning/androidhacks/hack030/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 Manning | ||
* See the file license.txt for copying permission. | ||
******************************************************************************/ | ||
package com.manning.androidhacks.hack030; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.manning.androidhacks.hack030.adapter.CountryAdapter; | ||
import com.manning.androidhacks.hack030.model.Country; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ListView; | ||
import android.widget.Toast; | ||
|
||
public class MainActivity extends Activity { | ||
private ListView mListView; | ||
private CountryAdapter mAdapter; | ||
private List<Country> mCountries; | ||
private String mToastFmt; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
createCountriesList(); | ||
mToastFmt = getString(R.string.activity_main_toast_fmt); | ||
mAdapter = new CountryAdapter(this, -1, mCountries); | ||
mListView = (ListView) findViewById(R.id.activity_main_list); | ||
mListView.setAdapter(mAdapter); | ||
} | ||
|
||
public void onPickCountryClick(View v) { | ||
int pos = mListView.getCheckedItemPosition(); | ||
|
||
if (ListView.INVALID_POSITION != pos) { | ||
String msg = String.format(mToastFmt, mCountries.get(pos) | ||
.getName()); | ||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
|
||
private void createCountriesList() { | ||
mCountries = new ArrayList<Country>(Countries.COUNTRIES.length); | ||
for (int i = 0; i < Countries.COUNTRIES.length; i++) { | ||
Country country = new Country(); | ||
country.setName(Countries.COUNTRIES[i]); | ||
mCountries.add(country); | ||
} | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
hack030/src/com/manning/androidhacks/hack030/adapter/CountryAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 Manning | ||
* See the file license.txt for copying permission. | ||
******************************************************************************/ | ||
package com.manning.androidhacks.hack030.adapter; | ||
|
||
import java.util.List; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
|
||
import com.manning.androidhacks.hack030.model.Country; | ||
import com.manning.androidhacks.hack030.view.CountryView; | ||
|
||
public class CountryAdapter extends ArrayAdapter<Country> { | ||
|
||
public CountryAdapter(Context context, int textViewResourceId, | ||
List<Country> objects) { | ||
super(context, textViewResourceId, objects); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
if ( convertView == null ) { | ||
convertView = new CountryView(getContext()); | ||
} | ||
|
||
Country country = getItem(position); | ||
|
||
CountryView countryView = (CountryView) convertView; | ||
countryView.setTitle(country.getName()); | ||
|
||
return convertView; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
hack030/src/com/manning/androidhacks/hack030/model/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012 Manning | ||
* See the file license.txt for copying permission. | ||
******************************************************************************/ | ||
package com.manning.androidhacks.hack030.model; | ||
|
||
public class Country { | ||
private String name; | ||
|
||
public Country() { | ||
|
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
} |
Oops, something went wrong.