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
若竹 雅貴
authored and
若竹 雅貴
committed
Mar 23, 2012
0 parents
commit 35c8b08
Showing
14 changed files
with
317 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,6 @@ | ||
.classpath | ||
.project | ||
project.properties | ||
assets/ | ||
bin/ | ||
gen/ |
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,5 @@ | ||
#Fri Mar 23 14:16:51 JST 2012 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.source=1.5 |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="jp.masaki.sp.parsexml" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="8" /> | ||
<uses-permission android:name="android.permission.INTERNET"></uses-permission> | ||
|
||
<application android:icon="@drawable/icon" android:label="@string/app_name"> | ||
<activity android:name=".ParseXMLActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="Rss"></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,11 @@ | ||
# 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 use, | ||
# "build.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-8 |
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,40 @@ | ||
-optimizationpasses 5 | ||
-dontusemixedcaseclassnames | ||
-dontskipnonpubliclibraryclasses | ||
-dontpreverify | ||
-verbose | ||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
|
||
-keep public class * extends android.app.Activity | ||
-keep public class * extends android.app.Application | ||
-keep public class * extends android.app.Service | ||
-keep public class * extends android.content.BroadcastReceiver | ||
-keep public class * extends android.content.ContentProvider | ||
-keep public class * extends android.app.backup.BackupAgentHelper | ||
-keep public class * extends android.preference.Preference | ||
-keep public class com.android.vending.licensing.ILicensingService | ||
|
||
-keepclasseswithmembernames class * { | ||
native <methods>; | ||
} | ||
|
||
-keepclasseswithmembers class * { | ||
public <init>(android.content.Context, android.util.AttributeSet); | ||
} | ||
|
||
-keepclasseswithmembers class * { | ||
public <init>(android.content.Context, android.util.AttributeSet, int); | ||
} | ||
|
||
-keepclassmembers class * extends android.app.Activity { | ||
public void *(android.view.View); | ||
} | ||
|
||
-keepclassmembers enum * { | ||
public static **[] values(); | ||
public static ** valueOf(java.lang.String); | ||
} | ||
|
||
-keep class * implements android.os.Parcelable { | ||
public static final android.os.Parcelable$Creator *; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<TextView | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/hello" | ||
/> | ||
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> | ||
<TextView android:text="押すとRSSを取得" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> | ||
</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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent"> | ||
<TextView android:layout_width="wrap_content" android:id="@+id/textViewTitle" android:text="TextView" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"></TextView> | ||
<TextView android:layout_width="wrap_content" android:id="@+id/textViewUrl" android:text="TextView" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall"></TextView> | ||
|
||
</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,9 @@ | ||
<?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="match_parent"> | ||
<ListView android:layout_height="wrap_content" android:id="@+id/listView1" android:layout_width="match_parent"></ListView> | ||
|
||
</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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="hello">Hello World, ParseXMLActivity!</string> | ||
<string name="app_name">ParseXML</string> | ||
</resources> |
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,31 @@ | ||
package jp.masaki.sp.parsexml; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class ParseXMLActivity extends Activity implements OnClickListener { | ||
final String mUrl = "http://spgirl.jp/feed/rss"; | ||
TextView tv1; | ||
/** Called when the activity is first created. */ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.main); | ||
tv1 = (TextView)findViewById(R.id.textView1); | ||
Button btn = (Button)findViewById(R.id.button1); | ||
btn.setOnClickListener(this); | ||
} | ||
|
||
public void onClick(View arg0) { | ||
// TODO Auto-generated method stub | ||
//ArrayList<Item> list = getArray(getURLStream(mUrl)); | ||
Intent intent = new Intent(); | ||
intent.setClassName("jp.masaki.sp.parsexml", "jp.masaki.sp.parsexml.Rss"); | ||
startActivity(intent); | ||
} | ||
} |
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,166 @@ | ||
package jp.masaki.sp.parsexml; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
import org.xmlpull.v1.XmlPullParser; | ||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.util.Xml; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.BaseAdapter; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
|
||
public class Rss extends Activity { | ||
TextView tv1; | ||
TextView tv2; | ||
static List<RssItem> dataList = new ArrayList<RssItem>(); | ||
static RssAdapter adapter; | ||
/** Called when the activity is first created. */ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.rss); | ||
|
||
//-----[xmlの取得先] | ||
String uri = "http://spgirl.jp/feed/rss"; | ||
|
||
//-----[httpクライアントの設定] | ||
HttpClient client = new DefaultHttpClient(); | ||
HttpGet get = new HttpGet(); | ||
|
||
try{ | ||
get.setURI(new URI(uri)); | ||
HttpResponse res = client.execute(get); | ||
InputStream in = res.getEntity().getContent(); | ||
|
||
//-----[パーサーの設定] | ||
XmlPullParser parser = Xml.newPullParser(); | ||
parser.setInput(in, "UTF-8"); | ||
|
||
//-----[アダプターの設定] | ||
//ArrayAdapter adapter; | ||
//adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1); | ||
RssAdapter adapter; | ||
adapter = new RssAdapter(); | ||
|
||
int eventType = parser.getEventType(); | ||
|
||
while(eventType != XmlPullParser.END_DOCUMENT) | ||
{ | ||
switch(eventType) | ||
{ | ||
case XmlPullParser.START_TAG: | ||
|
||
String tag = parser.getName(); | ||
if("title".equals(tag)){ | ||
String title = parser.nextText(); | ||
String link = null; | ||
if("link".equals(tag)){ | ||
link = parser.nextText(); | ||
}else{ | ||
link = "http://"; | ||
} | ||
//adapter.add(txt); | ||
dataList.add(new RssItem(title, link)); | ||
} | ||
break; | ||
case XmlPullParser.END_TAG: | ||
break; | ||
} | ||
eventType = parser.next(); | ||
} | ||
|
||
//-----[リストビューにアダプターをセット] | ||
ListView lv = (ListView)findViewById(R.id.listView1); | ||
lv.setAdapter(adapter); | ||
} | ||
catch (URISyntaxException e) { | ||
e.printStackTrace(); | ||
} | ||
catch (ClientProtocolException e) { | ||
e.printStackTrace(); | ||
} | ||
catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
catch (XmlPullParserException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private class RssAdapter extends BaseAdapter { | ||
public int getCount() { | ||
// TODO Auto-generated method stub | ||
return dataList.size(); | ||
} | ||
|
||
public Object getItem(int arg0) { | ||
// TODO Auto-generated method stub | ||
return dataList.get(arg0); | ||
} | ||
|
||
public long getItemId(int arg0) { | ||
// TODO Auto-generated method stub | ||
return arg0; | ||
} | ||
|
||
public View getView(int arg0, View arg1, ViewGroup arg2) { | ||
// TODO Auto-generated method stub | ||
View v = arg1; | ||
if(v==null){ | ||
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
v = inflater.inflate(R.layout.row, null); | ||
} | ||
RssItem rss = (RssItem)getItem(arg0); | ||
if(rss != null){ | ||
tv1 = (TextView) v.findViewById(R.id.textViewTitle); | ||
tv2 = (TextView) v.findViewById(R.id.textViewUrl); | ||
|
||
tv1.setText(rss.title); | ||
tv2.setText(rss.link); | ||
} | ||
return v; | ||
} | ||
|
||
} | ||
|
||
public class RssItem { | ||
String title; | ||
String link; | ||
String txt; | ||
public RssItem(String title, String link){ | ||
this.title = title; | ||
this.link = link; | ||
} | ||
|
||
public String getTxt(){ | ||
return txt; | ||
} | ||
|
||
public String getTitle(){ | ||
return title; | ||
} | ||
|
||
public String getlink(){ | ||
return link; | ||
} | ||
} | ||
} |