android 更多 收起 简单实现

private boolean moreflag = false;//初始化时给false  根据需求更改


txtMemo = (TextView) this.findViewById(R.id.memo);
txtMemo.setMaxLines(2);//初始化时设置最大行数为2两行

llyt_More = (LinearLayout) findViewById(R.id.housedetail_llyt_more);

// 更多
btn_More = (Button) findViewById(R.id.housedetail_btn_more);//更多文字
imgView_More = (ImageView) findViewById(R.id.housedetail_imgview_more);// 图片  向上  向下
btn_More.setOnClickListener(ocMore);//监听点击事件


/**
* 更多按钮
*/
private OnClickListener ocMore = new OnClickListener()
{


@Override
public void onClick(View v)
{
if (moreflag)
{
imgView_More.setImageResource(R.drawable.infomoredown);
txtMemo.setMaxLines(2);
btn_More.setText("更多");
moreflag = false;
}
else
{
imgView_More.setImageResource(R.drawable.infomoreup);
txtMemo.setMaxLines(200);
btn_More.setText("收起");
moreflag = true;
}
}
};

效果图











发布了3 篇原创文章 · 获赞 4 · 访问量 1087

猜你喜欢

转载自blog.csdn.net/maziqiang1993/article/details/9996735