收藏点赞代码,发表评论代码

/**
     * 判断对话框中是否输入内容
     */
    private boolean isEditEmply(){
        comment = commentEdit.getText().toString().trim();
        if(comment.equals("")){
            Toast.makeText(getApplicationContext(), "评论不能为空", Toast.LENGTH_SHORT).show();
            return false;
        }
        commentEdit.setText("");
        return true;
    }

    /**
     * 发表评论
     */
    private void publishComment(){
        TuPianXiangQingPingLunBean bean = new TuPianXiangQingPingLunBean();
        bean.setId(count);
        bean.setCommentImgId(imgs[count%4]);
        bean.setCommentNickname("昵称"+count);
        bean.setCommentTime("13:"+count%6+"5");
        bean.setCommnetAccount("12345"+count);
        bean.setCommentContent(comment);
        comments.add(bean);
        count++;
        adapter.notifyDataSetChanged();
    }

    /**
     * 显示或隐藏输入法
     */
    private void onFocusChange(boolean hasFocus){
        final boolean isFocus = hasFocus;
        (new Handler()).postDelayed(new Runnable() {
            public void run() {
                InputMethodManager imm = (InputMethodManager)
                        commentEdit.getContext().getSystemService(INPUT_METHOD_SERVICE);
                if(isFocus)  {
                    //显示输入法
                    imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                }else{
                    //隐藏输入法
                    imm.hideSoftInputFromWindow(commentEdit.getWindowToken(),0);
                }
            }
        }, 100);
    }

收藏点赞代码,发表评论代码_第1张图片

你可能感兴趣的:(收藏点赞代码,发表评论代码)