仿微信评论功能的简单实现

本文介绍了如何在项目中实现仿微信的评论功能,通过展示效果图和关键代码,讲解了使用popupwindow来创建评论框的步骤。
摘要由CSDN通过智能技术生成

在最近做的项目中有碰到要写类似朋友圈的模块,因为要实现评论点赞功能,这里说下我是怎么实现评论功能的。
首先先放上效果图
这里写图片描述
这里贴上我的代码:

//给评论图标设置点击事件
  mIv_header_discuss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupcomment();
            }
        });

showPopupcomment()方法如下

 private PopupWindow popupWindow;
    private View popupView = null;
    private EditText inputComment;
    private String nInputContentText;
    private TextView btn_submit;
    private RelativeLayout rl_input_container;
    private InputMethodManager mInputManager;
    @SuppressLint("WrongConstant")
    private void showPopupcomment() {
        if (popupView  == null){
        //加载评论框的资源文件    
            popupView =  LayoutInflater.from(context).inflate(R.layout.comment_popupwindow, null);
        }
        inputComment = (EditText) popupView.findViewById(R.id.et_discuss);
        btn_submit = (Button) popupView.findViewById(R.id.btn_confirm);
        rl_input_container = (RelativeLayout)popupView.findViewById(R.id.rl_input_container);
        //利用Timer这个Api设置延迟显示软键盘,这里时间为200毫秒
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {

            public void run()
            {
                mInputManage
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值