textView.setLines(int lines)不适用于textview。

时间:2014-03-25 15:40:18

标签: android textview android-adapter

我有ListView适配器,textview setLines不起作用。

在方法内:

public View getView(int position, View convertView, ViewGroup parent) {

我有这段代码:

    holder.title.post(new Runnable() {

        @Override
        public void run() {

            int lineCount    = holder.title.getLineCount();

            LogUtils.log("LINE_NUMBERS: " + lineCount+"");

            if(lineCount == 2){
                descriptionLineAmount = 6;
                holder.description.setLines(descriptionLineAmount);
            } else {
                descriptionLineAmount = 4;
                holder.description.setLines(descriptionLineAmount);
            }
        }
    });

描述行号没有改变(单元格没有用额外的行更新)。

1 个答案:

答案 0 :(得分:0)

在onclick中写这个:      ViewHolder tagHolder =(ViewHolder)v.getTag();

然后使用tagHolder代替持有者