我想在现有的 TextView 上添加一个简单的“阅读更多”/“阅读更少”按钮,并结合另一个..
我这样做了:
this.announcer_description = (TextView) findViewById(R.id.announcer_description);
this.readmore = (TextView) findViewById(R.id.readmore);
this.readmore.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (readmore.getText().equals("Read More"))
{
announcer_description.setText("");
announcer_description.setText(currentAnnouncer.getDescription_fr());
readmore.setText("");
readmore.append("Read less");
}
else if (readmore.getText().equals("Read less"))
{
announcer_description.setText("");
announcer_description.setText(shortDesc);
readmore.setText("");
readmore.append("Read more");
}
}});
我的“announcer_description”TextView 被初始化为“Read more”..但这不起作用..我发现使用 Read more 和 Read Less 的唯一方法是在这个 OnClickListener 中嵌套一些 OnClickListener ..
有人有想法吗?