简体   繁体   English

editText.getText().append 在片段中不起作用

[英]editText.getText().append in fragment is not working

i use customlistener in adapter(used for recyclerview).我在适配器中使用 customlistener(用于 recyclerview)。 if view is clicked, i handle the event in fragment.如果单击视图,我会在片段中处理事件。 (the event is editText.getText().append) problem is my customlistener is work well but i can append texts and when i check edittext by using editText.getText,then there is not thing... (事件是 editText.getText().append) 问题是我的 customlistener 运行良好,但我可以附加文本,当我使用 editText.getText 检查 edittext 时,就没有东西了...

public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState){
final View root=inflater.inflate(R.layout.fragment,container,false)
editText=root.findViewById(R.Id.editText);
ad.setOnItenListener(new webTomainadaper.OnItemClickListener(){
public void OnItemClick(String s, int position){
editText.getText().append(s);
}
})}

Use

editText.setText().append(editText.getText().append(s));

What you were doing is that you are only requesting the text inside the editText , not updating the view (editText)您所做的是您只请求 editText 内的文本,而不是更新视图(editText)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM