Implementation process of Android comment function

At present, various app communities or places where users sun photos and send comments provide a comment function. In order to learn better, I realized this function and made a small demo.

Firstly, a practical plug-in layoutcreator is recommended to help developers automatically generate layout code. For specific usage, go to gihub:

GitHub address: https://github.com/boredream/BorePlugin

1. Create a new Android project and write the layout of mainactivity_ main. xml

2. Create item layout of comment content entity class, content adapter and content

1) Content entity class comment

2) Content adapter adaptercomment

3) Item layout of content item_ comment. xml

3. Select the layout in mainactivity, and then click code - > layoutcreator in the menu bar. After confirming the layout code to be generated, click confirm to finish

Next, I'll improve the implementation. I've made comments in the code, so I won't be specific

be careful:

Because there are many types of Android phones, the bottom input box and input method overlap in some phones. As shown in the figure below, there is no part with a red circle:

When this problem occurs, you can go to manifest XML file, add an attribute to the corresponding activity

android:windowSoftInputMode="stateHidden|adjustResize"

In this way, the input method can be automatically adjusted to display the part with red circle, and the bottom input box and input method will not overlap.

4. The final rendering is as follows

Hide the interface of the input box

Display interface of input box

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
分享
二维码
< <上一篇
下一篇>>