Rss

K

Kapvoys344

Neues Mitglied
0
Hallo ,
Ich würde gerne ein RSS App machen nur leider finde keine gute Tutoria.
Freue mich auf jede Hilfe.
Bis jetzt siet mein Projekt so aus:
 

Anhänge

  • RSS-ZIP-Archiv.zip
    68,1 KB · Aufrufe: 55
ALso hab einige Tutoria gelesen und trozdem nix gebacken gekriegt.
Zur zeit sehen meine COde so aus:

main.xml
Code:
<?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:id="@+id/label"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="Enter RSS URL:"
  />
  
  <EditText
  android:id="@+id/rssURL"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:background="@android:drawable/editbox_background"
  android:text="http://www.rss-nachrichten.de/service/rss-feeds.xml"
  />
  

  <Button
      android:id="@+id/fetchRss"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginRight="10dip"
      android:text="Fetch Rss" />

  <ListView
  android:id="@+id/rssListView"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" />
</LinearLayout>

RSS_item_displayer.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
 >
 
 <TextView
  android:id="@+id/titleTextView"
   android:text="Title:"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:padding="10dp"
  android:textSize="13sp"
  android:autoLink="all"
  />
 
 <TextView
  android:id="@+id/contentTextView"
  android:text="Content:"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:textSize="13sp"
  android:autoLink="all"
  />
  
</LinearLayout>


RSSActivity.java
Code:
package rembo.network.urss;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import java.util.*;
import android.view.View;
import android.content.*;
public class RSSactivity extends Activity {
  
  public static RssItem selectedRssItem = null;
  String feedUrl = "";
  ListView rssListView = null;
  ArrayList<RssItem> rssItems = new ArrayList<RssItem>();
  ArrayAdapter<RssItem> aa = null;

  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // get textview from our layout.xml
    final TextView rssURLTV = (TextView) findViewById(R.id.rssURL);

    // get button from layout.xml
    Button fetchRss = (Button) findViewById(R.id.fetchRss);

    // define the action that will be executed when the button is clicked.
    fetchRss.setOnClickListener(new View.OnClickListener() {

      //@Override
      public void onClick(View v) {
        feedUrl = rssURLTV.getText().toString();
        //TextView TVtitle=(TextView)findViewById(R.id.label);
        //CharSequence cs="fetching";
        //TVtitle.setText(cs);
        aa.notifyDataSetChanged();
        refressRssList();
        //cs="Feed:";
        //TVtitle.setText(cs);
      }
    });

    // get the listview from layout.xml
    rssListView = (ListView) findViewById(R.id.rssListView);
    // here we specify what to execute when individual list items clicked
    rssListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

      //@Override
      public void onItemClick(AdapterView<?> av, View view, int index,
          long arg3) {
        selectedRssItem = rssItems.get(index);

        // we call the other activity that shows a single rss item in
        // one page
        Intent intent = new Intent(
            "rembo.network.urss.displayRssItem");
        startActivity(intent);
      }
    });

        //adapters are used to populate list. they take a collection,
        //a view (in our example R.layout.list_item
    aa = new ArrayAdapter<RssItem>(this, R.layout.list_item, rssItems);
        //here we bind array adapter to the list
    rssListView.setAdapter(aa);
    feedUrl = rssURLTV.getText().toString();
    refressRssList();
  }

  private void refressRssList() {

    ArrayList<RssItem> newItems = RssItem.getRssItems(feedUrl);

    rssItems.clear();
    rssItems.addAll(newItems);

    //TextView TVtitle=(TextView)findViewById(R.id.label);
    //CharSequence cs="0";
    //if(newItems.size()>0) cs="is 1";
    //if(newItems.size()>5) cs="is 5";
    ///TVtitle.setText(cs);
    
    aa.notifyDataSetChanged();
  }

}
RssItemDesplayer.java
Code:
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import java.text.*;

public class RssItemDisplayer extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rss_item_displayer);

    RssItem selectedRssItem = RSSactivity.selectedRssItem;
    //Bundle extras = getIntent().getExtras();
    TextView titleTv = (TextView)findViewById(R.id.titleTextView);
    TextView contentTv = (TextView)findViewById(R.id.contentTextView);

    String title = "";
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd - hh:mm:ss");
    title = "\n" + selectedRssItem.getTitle() + "  ( "
        + sdf.format(selectedRssItem.getPubDate()) + " )\n\n";

    String content = "";
    content += selectedRssItem.getDescription() + "\n"
        + selectedRssItem.getLink();

    titleTv.setText(title);
    contentTv.setText(content);
  }
}

uRSS Manifest
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="rembo.network.urss"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".URSSActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
  <uses-permission android:name="android.permission.INTERNET" />
</manifest>

Hoffe einer kann helfen.
 
naja du kannst nicht erwarten, dass sich jemand deinen kompletten code durchliest.

was genau geht denn nicht? markier doch die entsprechenden stellen. dann ist es auch wahrscheinlicher, dass du hilfe bekommst
 

Ähnliche Themen

lordzwieback
  • lordzwieback
Antworten
0
Aufrufe
710
lordzwieback
lordzwieback
F
  • Ferox77
Antworten
2
Aufrufe
616
burgerohnealles
B
M
Antworten
1
Aufrufe
751
DieGoldeneMitte
DieGoldeneMitte
Zurück
Oben Unten