在android的listview中更改baseadapter中linearlayout的高度和宽度运行时?

在android的listview中更改baseadapter中linearlayout的高度和宽度运行时?,android,height,width,android-linearlayout,Android,Height,Width,Android Linearlayout,我想更改listview中使用的linearlayout的高度如何更改该布局的高度和宽度我将把代码放在这里,但不更改linearlayout的高度如何执行此操作 <LinearLayout android:id="@+id/layoutadvertise" android:layout_width="fill_parent" android:layout_height="wrap_con

我想更改listview中使用的linearlayout的高度如何更改该布局的高度和宽度我将把代码放在这里,但不更改linearlayout的高度如何执行此操作

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>
Home.xml

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>

Homelist.xml

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>

AdapterClass.java

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>
公共类LazyAdapterHomeAdapter{
私有静态最终字符串标记\u SHOWTEXT=“SHOWTEXT”;
字符串显示文本;
私有静态最终字符串TAG\u PRODUCTINFO=“product\u info”;
字符串productinfo;
私有静态最终字符串标记_THUMBIMAGE=“thumbsrc”;
字符串图像;
私有静态最终字符串标记_DISTANCE=“DISTANCE”;
私人活动;
私有数组列表结果;
专用静态充气机=空;
公共GridImageLoader GridImageLoader;
图像宽度;
int图像高度;
语境;
整数宽度;
内部高度;
公众懒散适应家庭广告(活动a,ArrayList r){
活动=a;
结果=r;
充气器=(LayoutInflater)activity.getSystemService(Context.LAYOUT\u充气器\u SERVICE);
gridimageLoader=新的gridimageLoader(activity.getApplicationContext());
宽度=a.getWindowManager().getDefaultDisplay().getWidth();
高度=a.getWindowManager().getDefaultDisplay().getHeight();
图像宽度=((宽度/2)-5);
图像高度=(高度*25)/100;
}
public int getCount(){
返回result.size();
}
公共对象getItem(int位置){
返回位置;
}
公共长getItemId(int位置){
返回位置;
}
公共静态类视图持有者
{
公共文本查看文本宣传;
公共文本视图textkm;
公共图像查看图像广告;
}
公共视图getView(int位置、视图转换视图、视图组父视图){
视图vi=转换视图;
LinearLayout main=(LinearLayout)vi.findViewById(R.id.mainlayout);
main.setLayoutParams(新的LinearLayout.LayoutParams(imageWidth,imageheight));
视窗座;
if(convertView==null)
{
vi=充气机充气(R.layout.homelist,空);
holder=新的ViewHolder();
holder.textpromotional=(TextView)vi.findViewById(R.id.textpromotional);
holder.textkm=(TextView)vi.findViewById(R.id.textkm);
holder.ImageAdvertised=(ImageView)vi.findViewById(R.id.ImageAdvertised);
vi.setTag(支架);
}
其他的
holder=(ViewHolder)vi.getTag();
holder.textpromotional.setText(result.get(position.get(TAG_SHOWTEXT));
holder.textkm.SETEXT(结果.get(位置).get(标记距离));
holder.imageadvertise.setTag(result.get(position.get(TAG_THUMBIMAGE));
gridimageLoader.DisplayImage(result.get(position).get(TAG\u THUMBIMAGE),activity,holder.imageAdvertised);
返回vi;
}
公共静态浮点convertDpToPixel(浮点dp,上下文){
Resources=context.getResources();
DisplayMetrics=resources.getDisplayMetrics();
浮点数px=dp*(度量密度dpi/160f);
返回px;
}
}

从您的xml中删除android\u权重属性使用android:layout\u height=“120dp”您的愿望

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>
例如:

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>

从您的xml中删除android\u权重属性使用android:layout\u height=“120dp”您的愿望

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>
例如:

            <LinearLayout   android:id="@+id/layoutadvertise"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:padding="2dp"
                 >



  </LinearLayout>


remove android:layout\u weight在所有情况下为android:layout\u height=“120dp”提供dp中的值。然后,这将起作用,这是您的编程错误。您可能无法在(LazyAdapterHomeAdvised.java:100)中初始化要查看的值。remove android:layou\u weight在所有情况下为android:layout\u height=“120dp”提供值您在dp中的值。然后它将起作用,这是您的编程错误。您可能无法在(LazyAdapterHomeAdvised.java:100)中初始化要查看的值