我的 activity_main.xml 第 13 行有一个错误(您可以在下面看到)。它说“解析 XML 时出错:格式不正确(无效令牌)”。除此之外,我的 R.java 已经自杀了。我已经找到了修复它的方法,但是在修复此错误之前,它们将无法正常工作(至少我认为是因为这个)。感谢您的帮助。顺便说一句,我正在关注Javacodegeeks.com上的教程
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mynamespace="http://schemas.android.com/apk/res/com.Learning.learning"
xmlns:tools="http://schemas.android.com/tools"
mynamespace:layout_width="success"
mynamespace:orientation="vertical"
mynamespace:layout_height="success">
<ListView android:id="@+id/listView"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
List<Map<String>> planetsList = new ArrayList<Map<String,String>>() />
private void initList() {
//we populate them Planets
planetsList.add(createPlanet("planet", "Mercury"));
planetsList.add(createPlanet("planet", "Venus"));
planetsList.add(createPlanet("planet", "Earth"));
planetsList.add(createPlanet("planet", "Mars"));
planetsList.add(createPlanet("planet", "Jupiter"));
planetsList.add(createPlanet("planet", "Saturn"));
planetsList.add(createPlanet("planet", "Uranus"));
planetsList.add(createPlanet("planet", "Neptune"));
}
private HashMap<String, String> createPlanet(String key, String name) {
HashMap<String, String> planet = new HashMap<String, String>();
planet.put(key, name);
return planet;
}
// This is a simple adapter that accepts as parameter
// Context
// Data List
// The row layout that is used during the row creation
// The keys used to retrieve the data
// The View id used to show the data. The number and the view must match
simpleAdpt = new SimpleAdapter(this, planetsList, android.R.layout.simple_list_item_1, new String []
{"planet"}, new int[] {android.R.id.text1});
</ListView>