实施此类布局的最佳解决方案是:
我试过:
答案 0 :(得分:-1)
为列表视图项创建自定义布局。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:id="@+id/evenSideLayout"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="25dp"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/oddSideLayout"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
现在在您的自定义适配器中...管理布局可见性。像
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.item_option_layout, parent,
false);
LinearLayout oddLayout = (LinearLayout) convertView.findViewById(R.id.oddLayout);
LinearLayout evenLayout = (LinearLayout) convertView.findViewById(R.id.evenLayout);
if(position%2==0)
{
evenLayout.setVisibility(View.VISIBLE);
oddLayout.setVisibility(View.GONE);
}
else
{
evenLayout.setVisibility(View.GONE);
oddLayout.setVisibility(View.VISIBLE);
}
return convertView;
}