首页 > 解决方案 > TextView 不会更改其文本

问题描述

您好,我的 TextView 有问题。这是我的代码

final TextView username = (TextView) _v.findViewById(R.id.username);
final LinearLayout linear7 = (LinearLayout) _v.findViewById(R.id.linear7);
final TextView date = (TextView) _v.findViewById(R.id.date);
final TextView msg = (TextView) _v.findViewById(R.id.msg);
final TextView username2 = (TextView) _v.findViewById(R.id.username);
final LinearLayout linear72 = (LinearLayout) _v.findViewById(R.id.linear7);
final TextView date2 = (TextView) _v.findViewById(R.id.date);
final TextView msg2 = (TextView) _v.findViewById(R.id.msg);
final LinearLayout linear999 = (LinearLayout) _v.findViewById(R.id.linear999);
final LinearLayout linear9992 = (LinearLayout) _v.findViewById(R.id.linear9992);

username.setText(map1.get((int)_position).get("name").toString());
msg.setText(map1.get((int)_position).get("msg").toString());
date.setText(map1.get((int)_position).get("date").toString());
username2.setText(username.getText().toString());
msg2.setText(msg.getText().toString());
date2.setText(date.getText().toString());

如您所见,username2 应该与用户名具有相同的文本。但是,它只有我在设计器中为它提供的文本。请帮忙。

标签: javaandroidtextview

解决方案


看看yout的id 是TextView一样的。改成2号连接的idTextView

 final TextView msg = (TextView) _v.findViewById(R.id.msg);

 final TextView msg2 = (TextView) _v.findViewById(R.id.msg); <--- change this ID

推荐阅读