300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > android实现新闻内容显示功能 Android 类似新闻界面评论框

android实现新闻内容显示功能 Android 类似新闻界面评论框

时间:2020-07-18 15:33:02

相关推荐

android实现新闻内容显示功能 Android 类似新闻界面评论框

/**

* 初始化dialog

*/

private void showDialog() {

Dialog dialog =new Dialog(this);

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

dialog.setContentView(R.layout.popu_comment);

Window dialogWindow = dialog.getWindow();

dialogWindow.setGravity(Gravity.BOTTOM);

dialogWindow.getDecorView().setPadding(0, 0, 0, 0);

WindowManager.LayoutParams lp = dialogWindow.getAttributes();

lp.width = WindowManager.LayoutParams.MATCH_PARENT;

lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

dialogWindow.setAttributes(lp);

dialog.show();

//查找控件

EditText edComment = dialog.findViewById(R.id.ed_comment);

TextView btnFaBu = dialog.findViewById(R.id.btn_fabu_pl);

btnFaBu.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

dialog.dismiss();

//提交之后要讲str清空

str ="";

//展示框复原

tvContent.setText("请输入您的评论内容");

}

});

//判断有没有编辑过评论内容 如果编辑过就在显示出来

if (!TextUtils.isEmpty(str)) {

edComment.setText(str);

edComment.setSelection(str.length());//将光标移至文字末尾

}

//添加监听

edComment.addTextChangedListener(new TextWatcher() {

@Override

public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override

public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override

public void afterTextChanged(Editable editable) {

str =edComment.getText().toString();

tvContent.setText(str);

}

});

showSoft();

dismissSofo(dialog);

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。