Android implements Notepad app

Write a simple Notepad app yourself. The effect is as follows:

1、 The first is the preparation of the first interface, with a textview at the top, a listview layout nested in a linear layout in the middle, and a button at the bottom. A simple layout XML file for the first page is attached below.

As for the style of button, BTN_ A selector is a button style defined by itself.

2、 The second is to set the XML file for data display in listview. The code is as follows:

3、 Write the second interface style. The second interface is the uppermost linear layout, which contains two buttons and a textview. The code is as follows:

4、 Save the log data in the database and use SQLite to create the database. The database has three attributes, "_id", "content" and "date". Create a notedb to create the database.

5、 Jump to click add event. After clicking Add memo on the first page, it will jump to the second interface, set click event, and jump from one activity to another. I use intent mode. In addition, clicking each recorded log in the listview will also jump to the second interface, but the EditText containing the log is not displayed as a blank EditText. Mainactivity is as follows:

6、 Write the activity of the second interface after jump, as follows:

7、 Among them, onitemlongclicklistener is added to the listview. After long clicking, a dialog box will pop up to remind you whether to delete the log file.

Note: finally, set the return value to true, otherwise it will conflict with onitemclicklistener.

Attach the effect of long click deletion.

At the end, I attach my own code. I wrote it hard. I don't charge much resources. Those who are interested can download it.

Download link

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>