昨天晚上我有2個錯誤。今天早上我打開了這個項目,突然間有22個錯誤。你可以在下面看到我的代碼。我從導入android無法解析
http://www.javacodegeeks.com/2013/06/android-listview-tutorial-and-basic-example.html
得到這個代碼示例的錯誤如下: 1 *的java.lang.Object類型不能得到解決。它是間接引用的 必需的.class文件 1 *無法解析java.lang.String類型。它間接地從.class文件所需 引用 2 *進口java.util中不能得到解決 6 *導入機器人不能得到解決 2 *活動不能被解析爲一個類型 2 *覆寫不能被解析到一個類型 2 * ListView無法解析爲類型 1 *類型MainActivity未定義setContentView(int)方法 4 *字符串無法解析爲類型。 1 *方法findViewById(int)未定義類型
我希望這個問題不是太愚蠢。我已經嘗試了一些我在stackoverflow上找到的東西,但他們沒有工作。 感謝您的幫助和萬聖節快樂。
package ch.enerator.learning;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initList();
//We get the ListView component from the layout
ListView lv = (ListView) findViewById(R.id.listView);
// 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 key number and the view id must match
List<? extends Map<String, ?>> planetsList = null;
ListAdapter simpleAdpt = new SimpleAdapter(this, planetsList, android.R.layout.simple_list_item_1, new
String[] {"planet"}, new int[] {android.R.id.text1});
lv.setAdapter(simpleAdpt);
}
private void initList() {
// TODO Auto-generated method stub
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
但什麼是錯誤的? –
請粘貼錯誤日誌 –
好的抱歉,這是愚蠢的。我已經編輯過它們。有可能,某種文件被破壞了嗎?正如我所說的,這些錯誤基本上沒有任何意義。 – Marius