大家好!我正在學習一些java,並且已經將它寫入了記事本教程,當我在仿真器上運行它時,出現了一些錯誤,我希望這裏有人能夠提供幫助。在編譯應用程序時尋求2錯誤幫助
package com.a8a.todolist;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import android.view.View.OnClickListener;
public class ToDoList extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
//Inflat your view
setContentView(R.layout.main);
//Get references to UI widgets
ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText = (EditText)findViewById(R.id.myEditText);
//Create the array list of to do items
final ArrayList<String> todoItems = new ArrayList<String>();
//Create the array adapter to bind the array to the listview
final ArrayAdapter<String> aa;
**aa = new ArayAdapter<String>(this, android.R.layout.simple_list_item_1,todoItems);** *Multiple markers at this line - ArayAdapter cannot be resolved to a type - Line breakpoint:ToDoList [line: 27] - onCreate*
(Bundle)
//Bind the arary adapter to the listview.
myListView.setAdapter(aa);
**myEditText.setOnKeyListener(new OnKeyListener() {** *OnKeyListener cannot be resolved to a type*
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
{
todoItems.add(0, myEditText.getText().toString());
aa.notifyDataSetChanged();
myEditText.setText("");
return true;
}
return false;
}
});
}
}[/CODE]
加粗的文本是什麼得到的錯誤和斜體是錯誤本身。任何幫助,將不勝感激,如果你能夠解釋爲什麼需要改變,以及將不勝感激,所以我可以從我的錯誤中學習。
在此先感謝!
您需要發佈控制檯的logcat日誌,以便我們可以清楚地看到這些錯誤。 – Milan 2010-08-28 18:48:39
你用什麼工具編譯這段代碼?他們應該提醒你這些錯誤,並協助你在適當的進口 – 2010-08-28 18:50:28
@Aaron:+1;好點子。看着「多重標記」一點,我猜羅布正在使用Eclipse; @Rob:如果我是對的,看看http://depth-first.com/articles/2008/01/11/my-favorite-eclipse-shortcut-quick-fix – cubic1271 2010-08-28 19:14:22