在RelativeLayout的中心TextView的,当其他的TextView它为空(或不要有文字) [英] Center textview on RelativeLayout, when other textview it's null (or dont have text)

查看:107
本文介绍了在RelativeLayout的中心TextView的,当其他的TextView它为空(或不要有文字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着<一个href=\"http://blog.sptechnolab.com/2011/02/01/android/android-custom-listview-items-and-adapters/?replytocom=3075#respond\"相对=nofollow>此内容教程,现在它的工作很好,但是,我需要垂直居中标题的TextView,当详细信息的TextView文本它为空或空的,像我只有一个问题这个。我想这(http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/),和它的作品,但问题是,如果我使用setVisibility(View.GONE) ,来自所有项目,dissapear,只是题目的细节得到集中,任何帮助AP preciated,谢谢

编辑:修正了这种方式。

 字符串的DetailView =将String.valueOf(rowData.mDetail);
             detail.setText(的DetailView);
             detail.setVisibility(?detailView.equals(空)View.GONE:View.VISIBLE);


解决方案

记住调用setVisible(View.VISIBLE)当你再造一个视图。

 字符串细节=一些细节......;
detailTextView.setVisible(?详细== NULL View.GONE:View.VISIBLE);

希望这有助于

I followed this tutorial, for now it's working nice, but i only have a problem, i need to center vertically the "Title" textview, when "Detail" textview text it's null or empty, something like this. I tried this (http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/), and it works, but the problem it's that if i use setVisibility(View.GONE), all the details from all the items, dissapear, and just title get centered., any help appreciated, thanks

EDIT: Fixed this way

String detailView = String.valueOf(rowData.mDetail);
             detail.setText(detailView);
             detail.setVisibility(detailView.equals("null") ? View.GONE : View.VISIBLE);

解决方案

Remember to setVisible(View.VISIBLE) when you are recycling a view.

String detail = "some detail....";
detailTextView.setVisible(detail == null ? View.GONE : View.VISIBLE);

Hope this helps

这篇关于在RelativeLayout的中心TextView的,当其他的TextView它为空(或不要有文字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆