gpt4 book ai didi

Android Listview Rows 需要全屏

转载 作者:太空狗 更新时间:2023-10-29 16:04:02 30 4
gpt4 key购买 nike

在我的程序中,我使用的是 Universal Image Loader。在我的 ListView 中,行大小占据了我搜索过的所有屏幕,但我找不到导致它的原因,所以这是我的适配器

public class DynamicListView extends BaseAdapter {

ImageLoader imageLoader;
Context c;
String[] images= {"http://3.bp.blogspot.com/-Gsj-34Iyiio/ULEiyinE28I/AAAAAAAADPg/ISUQwGzSBMs/s1600/twitter.png",
"http://a1.mzstatic.com/us/r30/Purple6/v4/99/ee/8e/99ee8e01-f089-d549-f571-1a3797ec660d/icon_256.png" ,
"http://www.wallsave.com/wallpapers/1920x1080/forces-of-nature/1526282/forces-of-nature-1526282.jpg"};
String baslik="Bslik bla bla bla bla bla";
String icerik="Icerik bla bla bla bla bla";
ArrayList<ListViews> lists = new ArrayList<ListViews>();

DynamicListView(Context c )
{
this.c = c;
imageLoader = ImageLoader.getInstance();

for(int i= 0 ; i < 3 ; i++)
{
lists.add( new ListViews(images[i],baslik,icerik));
}
}

@Override
public int getCount() {
return lists.size();
}

@Override
public Object getItem(int position) {
return lists.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
myViewHolder holder = null;
if(row==null)
{
LayoutInflater inflate = (LayoutInflater) c.getSystemService(c.LAYOUT_INFLATER_SERVICE);//Butun layout u inflate'in icine aldik
row = inflate.inflate(R.layout.dynamic_lists , parent , false ); //gerekli islemler
holder = new myViewHolder(row);
row.setTag(holder);
}
else
{
holder = (myViewHolder) row.getTag();
}

imageLoader.displayImage(lists.get(position).image,holder.image );
holder.baslik.setText(lists.get(position).baslik);
holder.icerik.setText(lists.get(position).icerik);

return row;
}



class myViewHolder
{
private ImageView image;
private TextView baslik;
private TextView icerik;
myViewHolder(View v)
{
this.image = (ImageView) v.findViewById(R.id.ivDynamic);
this.baslik = (TextView) v.findViewById(R.id.tvDynamic1);
this.icerik = (TextView) v.findViewById(R.id.tvDynamic2);
}
}


class ListViews
{
ListViews(String image, String baslik, String icerik)
{
this.baslik = baslik;
this.icerik = icerik;
this.image = image;
}
String image;
String baslik;
String icerik;
}
}

这是我在 getView 方法中使用的单行

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background">

<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="@+id/ivDynamic"
android:background="#FFFFFF"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:text="Baslik bla bla"
android:id="@+id/tvDynamic1"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/ivDynamic"
android:paddingLeft="10dp"
android:layout_alignParentRight="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:text="Icerik bla bla bla"
android:id="@+id/tvDynamic2"
android:layout_alignBottom="@+id/ivDynamic"
android:layout_toRightOf="@+id/ivDynamic"
android:layout_below="@+id/tvDynamic1"
android:paddingLeft="7dp"
android:layout_alignParentRight="true" />
</RelativeLayout>

如有任何帮助,我们将不胜感激。

最佳答案

在RelativeLayout中设置android:layout_height="Wrap_content"

所以做这样的事情。

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="Wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background"> // You need to set proper size `background` image here

编辑:现在知道你的 android:background="@drawable/background" 可能有大尺寸。所以请检查 background 图像然后尝试。它可能会填满屏幕,因为您的 background 图像的尺寸大于屏幕尺寸。您需要在 drawable 中设置适当尺寸的 background 图像。

关于Android Listview Rows 需要全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21526069/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com