如何从同一片段的按钮onclickListner更新片段的textview。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(
R.layout.fragment_practicing_alphabet, container, false);
TextView singleAlphabet=(TextView) rootView.findViewById(R.id.single_alphabet);
ImageButton previousImage=(ImageButton) rootView.findViewById(R.id.btn_backward_arrow);
previousImage.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
String tempAlphaString=(String) singleAlphabet.getText();
char tempAlphaChar=(char) (tempAlphaString.charAt(0)+1);
singleAlphabet.setText(tempAlphaChar);
}});
访问singleAlphabet TextView时出现编译错误,如何查看textview,请给我一些如何更新textview的建议。
答案 0 :(得分:0)
尝试访问TextView,如下面的代码:
String tempAlphaString= single_Alphabet.getText().toString();
您可以通过
更新TextView single_Alphabet.setText("your text");