实现意见反馈剩余字数先看下效果图

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context="com.ranlegeran.feedbackdemo.MainActivity"><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dip"android:background="#FFFFFF"><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="意见反馈"android:textSize="18sp"android:textColor="#000000"/></RelativeLayout><LinearLayout
        android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><EditText
       android:id="@+id/et_content"android:layout_width="match_parent"android:layout_height="130dp"android:layout_marginTop="15dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:padding="8dp"android:gravity="left|top"android:hint="说点什么吧~我们会做得更好~"android:textSize="15sp"android:maxLength="200"android:background="@drawable/shape_et_bg"/><TextView
       android:id="@+id/text_count"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="15dp"android:layout_marginRight="10dp"android:layout_gravity="right"android:text="0/200"/></LinearLayout><Button
        android:id="@+id/btn_submit"android:layout_width="match_parent"android:layout_height="45dp"android:layout_marginTop="35dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:text="提交"android:textColor="#FFFFFF"android:textSize="16sp"android:background="@drawable/shape_btn_bg"/></LinearLayout>

用到的资源文件:shape_et_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle" ><solid android:color="#FFFFFF" /><stroke
        android:width="1px"android:color="#FFFFFF" /><padding
        android:bottom="1dp"android:left="1dp"android:right="1dp"android:top="1dp" /></shape>

shape_btn_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><solid android:color="#00CBAB"/><corners android:radius="10.0px"/><padding
        android:top="10dp"android:bottom="10dp"android:left="10dp"android:right="10dp"/></shape>

MainActivity部分

package com.ranlegeran.feedbackdemo;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;public class MainActivity extends AppCompatActivity {private static final int MAX_COUNT = 200;private EditText mEtContent = null;private TextView mTextCount = null;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mEtContent = (EditText) findViewById(R.id.et_content);mTextCount = (TextView) findViewById(R.id.text_count);mEtContent.addTextChangedListener(new TextWatcher() { //对EditText进行监听@Overridepublic void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}@Overridepublic void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}@Overridepublic void afterTextChanged(Editable editable) {mTextCount.setText("剩余字数:" + (MAX_COUNT - editable.length()));}});}
}

Android实现意见反馈剩余字数相关推荐

  1. “意见反馈”DEMO

    这个demo主要是最近我在做的项目中用到的.大致功能:用户写意见总数不能超过一千个字,右下角数字随着你写的字数n变成1000-n,当字数超过一千就无法再写入了.主要用到了TextView的addtex ...

  2. Android程序开发意见反馈的实现

    托更一个月,回学校弄论文.答辩.感触颇多,自己的人生一下子从学生跨度到社会,虽然是理科男,但是有一颗文科多情善感的心,(想吐的朋友请别忍着).只能说人生才刚刚开始,生命不息,奋斗不止. 下面介绍一下A ...

  3. Android意见反馈界面的制作

    在我们的android中我们的意见反馈界面的话就是设置我们的相关的方法 然后的话我们的意见反馈界面要用到的控件有: <?xml version="1.0" encoding= ...

  4. android矩形输入框,Android中实现在矩形框中输入文字显示剩余字数的功能

    虽然这两个功能都比较简单,但是在实际app开发中真的很常见,特别是显示字数或剩余字数这个功能 如下图: 要实现上面的功能,需要做到三点: 1.实现矩形框布局 思路就是矩形框作为整个布局的一个backg ...

  5. 为啥我的页面模板的from提交不了数据_4-9【微信小程序全栈开发课程】意见反馈(四)--提交反馈信息

    1.创建后端操作文件 先在后端server/controllers文件夹中创建操作文件createopinion.js,用来将从前端页面提交的数据,插入到opinions表中,创建完之后,页面目录如下 ...

  6. 集成友盟的意见反馈功能

    最近一直在开发毕业设计的项目,其中用到了很多自己没接触过的东西,就包括集成友盟SDK的意见反馈模块的内容了.确实用了一点心思在里面,捣鼓了一阵子,中间也遇到了一些问题,关键这问题也不好解决,问大神大神 ...

  7. html右下角的字数计算,JavaScript_用JS剩余字数计算的代码,先看看HTML代码: textarea name - phpStudy...

    用JS剩余字数计算的代码 先看看HTML代码: 文字最大长度: 250. 还剩: 250. 可以看出onkeyup是当用户离开键盘后触发的事件,传递的参数是this(也就是当前所在的文档区域) 然后结 ...

  8. 小程序意见反馈界面(简洁版代码)

    在开发个人中心页面时,意见反馈功能是必不可少的,下面介绍该功能的具体开发流程 1.首先看一下效果图: 2.WXML代码,分为三个部分,文本域(TextArea).输入框(Input).按钮(Butto ...

  9. 开箱即用——用模板快速生成《客户意见反馈表》

    简介:[开箱即用的模板使用系列教程]将会手把手教给大家如何快速启用钉钉宜搭提供各类模板.今天第二讲,介绍<客户意见反馈表>的模板启用. [开箱即用的模板使用系列教程]将会手把手教给大家如何 ...

最新文章

  1. 矩阵树定理2020HDU多校第6场j-Expectation[位运算+期望]
  2. irobot擦地机器人故障_自己动手修复 iRobot braava380t 电机故障
  3. 模式识别与智能系统和计算机视觉,天津大学模式识别与智能系统
  4. php 递归函数自调用函数,PHP闭包实现函数的自调用实现递归
  5. 案例 宠物医生给小动物看病 c# 1614100379
  6. 前端使用工具sublime text 3下载
  7. quicksort算法_QuickSort算法–用C,Java,Python实现
  8. 苹果Mac好用的SSH连接客户端工具:​​​​​​​​​​​​Termius
  9. PHP使用MySQL数据库
  10. VISIO——word中插入visio图片 图片边缘空白裁剪
  11. 【华为】某中小型企业网 组网案例—总公司+分公司模式
  12. 图文详解Unity3D中Material的Tiling和Offset是怎么回事
  13. 提问的智慧-如何明智到找到想要的答案
  14. 三菱机械臂demo程序
  15. 用手机打开word图表位置很乱_word排版技巧:论文图表目录制作步骤
  16. 我的K均值算法的matlab实现
  17. 风格对照表的制作与使用
  18. 《数学建模与数学实验》第5版 数据的统计描述 习题8.7
  19. Linux下串口编程
  20. 【STM32F130RCT6】超声波测距模块思路和代码

热门文章

  1. 32位真彩色与24位真彩色区别
  2. uci2019计算机录取,最新 | 加州大学各分校2019年申请数据公开,录取率再降低,凉到心底!...
  3. 史上最强Java架构师的13大技术能力讲解! | 附架构师能力图谱
  4. 新颖的自我介绍_有创意的自我介绍五篇
  5. R语言(地图摸索学习)——经纬度对应的地区名称
  6. Java JSF网上资源大全(持续更新)
  7. 视频教程-php初级到项目实战-PHP
  8. 国内外GIS流行软件之概述
  9. NXP(Freescale) QorIQ T2080 Memory Map分析
  10. 服务器Shell分析日志命令