前几天我遇到了新的Twitter API(版本3.1.1),我试图复制我在推文列表中看到的效果。如何处理ListView中的ViewStub
不幸的是我是一个新用户,我不能发表图片,所以我想解释一下我说的
有鸣叫(列表视图)的服务,您可以与互动他们由一个longKeyPressed。 只要您点击,选定的项目消失,并出现一个新的项目。在这个新的项目中有选择推文(转推,最喜欢的等...)的可用选项
我试图做一个这个功能的副本,但我有一个问题,我无法弄清楚。
让我们假设我们使用ViewStub以优化列表视图,这是该行
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ViewStub
android:id="@+id/twitter_stub"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:inflatedId="@+id/twitter_actions"
android:layout="@layout/twitter_swipe_actions" />
<LinearLayout android:id="theOneWhichHasToDisappear">
.....the row of the listVIew.....
<LinearLayout>
当我尝试设置的LinearLayout(“theOneWhichHasToDisappear”),以水涨船高的可见性的布局, everithing是凉的,这里是
v.findViewById(R.id.theOneWitchHasToDisappear).setVisibility(View.GONE);
//inflating the stubview
ViewStub stub = (ViewStub) v.findViewById(R.id.twitter_stub);
View inflated = stub.inflate();
但不幸的是我不能让该项目的适当高度(高度不应该在新的充气后更改)。 否则,当我更换列表上的项目时,其他项目会更改!例如当我点击列表中的第一项(第一条推文)时,数字1改变了视图,但数字4,8,12等也改变了!
有谁知道怎么办呢?谢谢
对不起,但即使设置了包含存根和行布局的RelativeLayout,高度仍然在变化! – oroblam 2012-03-14 10:09:54
您是否在RelativeLayout上设置了高度? – 2012-03-14 12:21:59
我的RelativeLayout的高度设置为android:layout_height =“wrap_content” – oroblam 2012-03-14 17:12:15