Skip to content

Commit ff95eed

Browse files
committed
544545
1 parent b51bc75 commit ff95eed

File tree

29 files changed

+682
-0
lines changed

29 files changed

+682
-0
lines changed

MyApplication_Animal.iml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
</configuration>
8+
</facet>
9+
</component>
10+
<component name="NewModuleRootManager" inherit-compiler-output="true">
11+
<exclude-output />
12+
<content url="file://$MODULE_DIR$">
13+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
14+
</content>
15+
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
16+
<orderEntry type="sourceFolder" forTests="false" />
17+
</component>
18+
</module>
19+

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/app.iml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="MyApplication_Animal" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="android-gradle" name="Android-Gradle">
5+
<configuration>
6+
<option name="GRADLE_PROJECT_PATH" value=":app" />
7+
</configuration>
8+
</facet>
9+
<facet type="android" name="Android">
10+
<configuration>
11+
<option name="SELECTED_BUILD_VARIANT" value="debug" />
12+
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
13+
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
14+
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
15+
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
16+
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
17+
<option name="ALLOW_USER_CONFIGURATION" value="false" />
18+
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
19+
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
20+
<option name="RES_FOLDERS_RELATIVE_PATH" value="" />
21+
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
22+
</configuration>
23+
</facet>
24+
</component>
25+
<component name="NewModuleRootManager" inherit-compiler-output="false">
26+
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
27+
<exclude-output />
28+
<content url="file://$MODULE_DIR$">
29+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
30+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
31+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
32+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
33+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
34+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
35+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
36+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
37+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
38+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
39+
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
40+
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
41+
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
42+
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
43+
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
44+
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
45+
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
46+
<sourceFolder url="file://$MODULE_DIR$/libs/src/main/res" type="java-resource" />
47+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
48+
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
50+
<sourceFolder url="file://$MODULE_DIR$/libs/src/main/java" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
57+
<sourceFolder url="file://$MODULE_DIR$/libs/src/androidTest/java" isTestSource="true" />
58+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
59+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
60+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
61+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
62+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
63+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
64+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
65+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
66+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
67+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
68+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
69+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
70+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
71+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
72+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
73+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
74+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
76+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
77+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
78+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
79+
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
80+
</content>
81+
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
82+
<orderEntry type="sourceFolder" forTests="false" />
83+
</component>
84+
</module>
85+

app/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 20
5+
buildToolsVersion "20.0.0"
6+
7+
defaultConfig {
8+
applicationId "com.example.gens.myapplication_animal"
9+
minSdkVersion 15
10+
targetSdkVersion 20
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/libs/src/main/AndroidManifest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.gens.myapplication_animal">
4+
5+
<application android:allowBackup="true" android:icon="@drawable/ic_launcher"
6+
android:label="@string/app_name" android:theme="@style/AppTheme">
7+
<activity android:name=".MyActivity" android:label="@string/app_name">
8+
<intent-filter>
9+
<action android:name="android.intent.action.MAIN" />
10+
11+
<category android:name="android.intent.category.LAUNCHER" />
12+
</intent-filter>
13+
</activity>
14+
</application>
15+
16+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
/**
4+
* Created by Gens on 05.11.2014.
5+
*/
6+
public abstract class Animal {
7+
private int mId;
8+
9+
private String mName;
10+
11+
public Animal(final int id, final String name) {
12+
mId = id;
13+
mName = name;
14+
}
15+
16+
public int getId() {
17+
return mId;
18+
}
19+
20+
public String getName() {
21+
return mName;
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
/**
4+
* Created by Gens on 05.11.2014.
5+
*/
6+
public class Cat extends Animal {
7+
public Cat(int id, String name) {
8+
super(id, name);
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
/**
4+
* Created by Gens on 05.11.2014.
5+
*/
6+
public class Doc extends Animal {
7+
public Doc(int id, String name) {
8+
super(id, name);
9+
}
10+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
import android.widget.ListView;
8+
9+
import java.util.ArrayList;
10+
11+
12+
public class MyActivity extends Activity {
13+
private static final int ITEMS_COUNT = 2;
14+
15+
@Override
16+
protected void onCreate(Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
setContentView(R.layout.activity_my);
19+
20+
//Получаем объекты Animal
21+
Cat cat = new Cat(0,"cat") ;
22+
//
23+
Doc doc = new Doc(1,"doc") ;
24+
//создаем ArrayList
25+
final ArrayList<Animal> items = new ArrayList<Animal>(ITEMS_COUNT);
26+
//ссылки
27+
Animal item_cat;
28+
Animal item_doc;
29+
30+
//инициализация
31+
item_cat = cat;
32+
item_doc = doc;
33+
34+
//добавляем
35+
items.add(item_cat);
36+
items.add(item_doc);
37+
38+
//инициализируем адаптер
39+
final MyAdapter adapter = new MyAdapter(this, R.layout.list_item_item, items);
40+
41+
//добавляем адаптер в ListView
42+
final ListView listView = (ListView) findViewById(R.id.myListView);
43+
listView.setAdapter(adapter);
44+
}
45+
@Override
46+
public boolean onCreateOptionsMenu(Menu menu) {
47+
// Inflate the menu; this adds items to the action bar if it is present.
48+
getMenuInflater().inflate(R.menu.my, menu);
49+
return true;
50+
}
51+
52+
@Override
53+
public boolean onOptionsItemSelected(MenuItem item) {
54+
// Handle action bar item clicks here. The action bar will
55+
// automatically handle clicks on the Home/Up button, so long
56+
// as you specify a parent activity in AndroidManifest.xml.
57+
int id = item.getItemId();
58+
if (id == R.id.action_settings) {
59+
return true;
60+
}
61+
return super.onOptionsItemSelected(item);
62+
}
63+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.example.gens.myapplication_animal;
2+
3+
/**
4+
* Created by Gens on 06.11.2014.
5+
*/
6+
import android.content.Context;
7+
import android.graphics.Color;
8+
import android.view.LayoutInflater;
9+
import android.view.View;
10+
import android.view.ViewGroup;
11+
import android.widget.ArrayAdapter;
12+
import android.widget.TextView;
13+
14+
import java.util.List;
15+
16+
public class MyAdapter extends ArrayAdapter <Animal> {
17+
18+
private final LayoutInflater mLayoutInflater;
19+
private final int mLayoutResId;
20+
21+
public MyAdapter(final Context context, final int resource, final List<Animal> objects) {
22+
super(context, resource, objects);
23+
24+
mLayoutInflater = LayoutInflater.from(context);
25+
mLayoutResId = resource;
26+
}
27+
28+
@Override
29+
public View getView(int position, View convertView, ViewGroup parent) {
30+
31+
final View view = mLayoutInflater.inflate(mLayoutResId, null);
32+
33+
final Animal item = getItem(position);
34+
if (position == 0){
35+
view.setBackgroundColor(Color.BLUE);
36+
} else {
37+
view.setBackgroundColor(Color.GRAY);
38+
}
39+
final TextView idTextView = (TextView) view.findViewById(R.id.idTextView);
40+
idTextView.setText(String.valueOf(item.getId()));
41+
42+
final TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
43+
nameTextView.setText(item.getName());
44+
45+
return view;
46+
}
47+
}
Loading
Loading
Loading
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:layout_width="fill_parent" android:layout_height="fill_parent">
3+
4+
<ListView android:id="@+id/myListView" android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
7+
/>
8+
</RelativeLayout>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent" android:layout_height="match_parent"
4+
android:orientation="vertical">
5+
6+
<TextView android:id="@+id/idTextView" android:layout_width="match_parent"
7+
android:layout_height="wrap_content" />
8+
9+
<TextView android:id="@+id/nameTextView" android:layout_width="match_parent"
10+
android:layout_height="wrap_content" />
11+
12+
</LinearLayout>

app/libs/src/main/res/menu/my.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools" tools:context=".MyActivity">
3+
<item android:id="@+id/action_settings" android:orderInCategory="100"
4+
android:showAsAction="never" android:title="@string/action_settings" />
5+
</menu>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="app_name">My Application_Animal</string>
5+
<string name="hello_world">Hello world!</string>
6+
<string name="action_settings">Settings</string>
7+
8+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
</style>
7+
8+
</resources>

0 commit comments

Comments
 (0)