我是 android 新手,我想创建记事本。我想创建带有水平线的编辑文本。我需要做什么?我的活动代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_task);
title = (TextView) findViewById(R.id.Listname);
Title_Edit = (EditText)findViewById(R.id.title_Edit);
content = (TextView) findViewById(R.id.content);
Content_Edit = (EditText)findViewById(R.id.content_Edit);
save = (Button)findViewById(R.id.Save);
cancel = (Button)findViewById(R.id.Cancel);
Intent intent1 = getIntent();
// titleEdit = intent1.getStringExtra("title");
contents = intent1.getIntExtra("content", 0);
isEdit = intent1.getBooleanExtra("isEdit", false);
System.out.println(contents + "Intent ID");
System.out.println(isEdit + "IS EDIT");
if(isEdit) {
Database_Notepad db = new Database_Notepad(Add_Task.this);
Cursor c = db.GetNote(contents);
Title_Edit.setText(c.getString(0));
Content_Edit.setText(c.getString(1));
System.out.println(c + "date from cursor");
db.close();
c.close();
}
save.setOnClickListener(this);
cancel.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.Save:
String get_title = Title_Edit.getText().toString();
String get_content = Content_Edit.getText().toString();
if(!get_title.equals("") || !get_content.equals(""))
{
if (!isEdit) {
//if it isn't edit mode we just add a new note to db
Database_Notepad db = new Database_Notepad(Add_Task.this);
db.Create_Note(get_title, get_content);
} else {
//if this is edit mode, we just update the old note
Database_Notepad db = new Database_Notepad(Add_Task.this);
db.updateNote(contents, get_title, get_content);
db.close();
}
}
请建议,我需要对编辑文本做什么。我还需要在xml中添加一些东西吗?