Skip to content

Commit 11f845f

Browse files
committed
first cast
1 parent 0164677 commit 11f845f

File tree

12 files changed

+148
-0
lines changed

12 files changed

+148
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

AndroidManifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="gg.common.app"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
8+
9+
<application
10+
android:icon="@drawable/ic_launcher"
11+
android:label="@string/app_name" >
12+
<activity android:name="gg.common.activity.Main"></activity>
13+
</application>
14+
15+
</manifest>

lint.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<lint>
3+
</lint>

proguard-project.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}

project.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-8

res/drawable-hdpi/ic_launcher.png

9.18 KB
Loading

res/drawable-ldpi/ic_launcher.png

2.67 KB
Loading

res/drawable-mdpi/ic_launcher.png

5.11 KB
Loading

res/drawable-xhdpi/ic_launcher.png

14 KB
Loading

res/layout/main.xml

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="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<TextView
8+
android:layout_width="fill_parent"
9+
android:layout_height="wrap_content"
10+
android:text="@string/hello" />
11+
12+
</LinearLayout>

res/values/strings.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="hello">Hello World!</string>
5+
<string name="app_name">XmlPullParserExample</string>
6+
7+
</resources>

src/gg/common/activity/Main.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package gg.common.activity;
2+
3+
import gg.common.app.R;
4+
5+
import java.io.IOException;
6+
7+
import org.xmlpull.v1.XmlPullParser;
8+
import org.xmlpull.v1.XmlPullParserException;
9+
10+
import android.app.Activity;
11+
import android.os.Bundle;
12+
import android.text.TextUtils;
13+
import android.util.Log;
14+
15+
public class Main extends Activity {
16+
17+
final String LOG_TAG = "myLogs";
18+
19+
/** Called when the activity is first created. */
20+
@Override
21+
public void onCreate(Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
setContentView(R.layout.main);
24+
String tmp = "";
25+
26+
try {
27+
XmlPullParser xpp = prepareXpp();
28+
29+
while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
30+
switch (xpp.getEventType()) {
31+
// начало документа
32+
case XmlPullParser.START_DOCUMENT:
33+
Log.d(LOG_TAG, "START_DOCUMENT");
34+
break;
35+
// начало тэга
36+
case XmlPullParser.START_TAG:
37+
Log.d(LOG_TAG, "START_TAG: name = " + xpp.getName()
38+
+ ", depth = " + xpp.getDepth() + ", attrCount = "
39+
+ xpp.getAttributeCount());
40+
tmp = "";
41+
for (int i = 0; i < xpp.getAttributeCount(); i++) {
42+
tmp = tmp + xpp.getAttributeName(i) + " = "
43+
+ xpp.getAttributeValue(i) + ", ";
44+
}
45+
if (!TextUtils.isEmpty(tmp))
46+
Log.d(LOG_TAG, "Attributes: " + tmp);
47+
break;
48+
// конец тэга
49+
case XmlPullParser.END_TAG:
50+
Log.d(LOG_TAG, "END_TAG: name = " + xpp.getName());
51+
break;
52+
// содержимое тэга
53+
case XmlPullParser.TEXT:
54+
Log.d(LOG_TAG, "text = " + xpp.getText());
55+
break;
56+
57+
default:
58+
break;
59+
}
60+
// следующий элемент
61+
xpp.next();
62+
}
63+
Log.d(LOG_TAG, "END_DOCUMENT");
64+
65+
} catch (XmlPullParserException e) {
66+
e.printStackTrace();
67+
} catch (IOException e) {
68+
e.printStackTrace();
69+
}
70+
}
71+
72+
XmlPullParser prepareXpp() {
73+
return getResources().getXml(R.xml.data);
74+
}
75+
}

0 commit comments

Comments
 (0)