大家好!我正在学习一些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