Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将初始大小设置为从BaseAdapter返回的LinearLayout';s getView方法_Android - Fatal编程技术网

Android 将初始大小设置为从BaseAdapter返回的LinearLayout';s getView方法

Android 将初始大小设置为从BaseAdapter返回的LinearLayout';s getView方法,android,Android,我正在尝试编写一个照片库,用GridView显示图像。图像是从远程位置加载的,我想在加载图像时显示水平进度条。这部分工作正常。我编写了从BaseAdapter扩展而来的自定义适配器。在我的getView方法中,我返回LinearLayout对象,该对象包含其中的ProgressBar对象,当图像加载完成时,它将被ImageView替换 这就是我的问题。与ImageView对象相比,进度条较薄(高度较小)。当画廊活动开始时,我看到很多进度条,然后它们开始“扩展”(因为图像的高度比进度条的高度大),

我正在尝试编写一个照片库,用GridView显示图像。图像是从远程位置加载的,我想在加载图像时显示水平进度条。这部分工作正常。我编写了从BaseAdapter扩展而来的自定义适配器。在我的getView方法中,我返回LinearLayout对象,该对象包含其中的ProgressBar对象,当图像加载完成时,它将被ImageView替换

这就是我的问题。与ImageView对象相比,进度条较薄(高度较小)。当画廊活动开始时,我看到很多进度条,然后它们开始“扩展”(因为图像的高度比进度条的高度大),这很难看。我想为在getView方法中返回的LinearLayout对象设置初始宽度和高度

谁能帮我实现这一点

这是我的密码:

public class GalleryAdapter extends BaseAdapter{

public View getView(int position, View convertView, ViewGroup parent){

    LinearLayout layout = new LinearLayout(activity);

    // Some code here to set initial width and height to layout


    // This is my image loader that puts progress bar in layout, 
    // loads image then replaces progrssbar with image
    new LoadAndShowImage(imageUrl, layout, onClick, memCache).execute();

    return layout;
}


}

我用另一种方式问了这个问题,得到了答案。是

我用另一种方式问了这个问题并得到了答案。是的