0
我目前正在嘗試在Android studio中使用ListView製作RSS閱讀器。我已經設法使ListView,但我不知道下一步該去哪裏。我似乎找不到任何好的教程在線我應該如何解決這個問題,而且我發現的任何東西都已過時3年。有小費嗎?Android Studio RSS閱讀器。
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.micha.rssreader.MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/listviewAD" />
MainActivity.java
package com.example.micha.rssreader;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
public ListView AdFeed; // maakt listview aan
public String[] items;
public ArrayAdapter<String> adapt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdFeed = (ListView)findViewById(R.id.listviewAD);
items = new String[]{"blue", "red", "black", "orange", "purpol"};
adapt = new ArrayAdapter<String>(this, R.layout.items, items);
AdFeed.setAdapter(adapt);//zet de data acther de listview
AdFeed.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
}
}