1

1.状態確認のみ表示

public View getView(final int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.main_alllatestnewslist, parent,
                false);     
    ImageView imageview = (ImageView) vi
            .findViewById(R.id.image_alllatestnewstitle);
    imageview.setVisibility(View.INVISIBLE);
    TextView titletext = (TextView) vi
            .findViewById(R.id.text_particularlatestnewstitle);
    TextView categorytext = (TextView) vi
            .findViewById(R.id.text_newscategorytitle);
    TextView datetext = (TextView) vi.findViewById(R.id.text_newsdate);

    if (!imagepath[position].toString().equals("no picture")) {
        imageLoader.DisplayImage(imagepath[position], imageview);
        imageview.setVisibility(View.VISIBLE);          
        titletext.setWidth(460 - imageview.getWidth() - 5); <-- this line   
    } else {
        imageview.setVisibility(View.INVISIBLE);
        imageview.setImageDrawable(null);
    }
    titletext.setText(title[position].toString());
    categorytext.setText(category[position].toString());
    datetext.setText(date[position].toString());

    return vi;
}

リストの最初の表示時にステートメントをチェックできず、textview が imageview とスタックする原因となります。1回以上スクロールした後、左にのみ移動します。

表示する前にこのステートメントに入る方法は?

2.条件に基づいてプログラムでリストビューのすべてのアイテムの高さを設定します

RelativeLayout childlayout = (RelativeLayout)vi.findViewById(R.id.layout_childlist);

アイテムのレイアウトです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_childlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/list_bg"
android:minHeight="?android:attr/listPreferredItemHeight" >
<LinearLayout
    android:id="@+id/test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="5px"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="5px" >

    <ImageView
        android:id="@+id/image_alllatestnewstitle"
        android:layout_width="140px"
        android:layout_height="80px"
        android:scaleType="centerCrop" />
</LinearLayout>
....
</RelativeLayout>

たとえば、アイテムの 1 つは表示に 80 ピクセルかかりましたが、他のアイテムは 40 ピクセルしかかかりませんでした。ただし、他のアイテムは 40px にラップされず、80px にラップされ、すべてのアイテムが同じ高さになります。

高さが異なるすべてのアイテムの高さを設定する方法は?

4

1 に答える 1

1

試すimageview.setVisibility(View.GONE);

INVISIBLEビューをGONE「削除」している間だけ非表示にします

于 2012-05-17T09:16:51.923 に答える