---
title: "android开发问题集"
author: "zhy584520"
date: "2014-04-04T15:31:14Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2014-04-04T15:31:14Z"
id: 2041143
url: "https://zhy584520.iteye.com/blog/2041143"
---

最近开始做安卓开发项目，记录一下在开发过程当中我所遇到的问题以及解决办法。

整理如下，博文将持续更新哦。。。。

1.继承BaseAdapter，在getView方法里加载一个视图，并设置视图的高度与宽度，设置方法如下：

convertView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH\_PARENT, UIShareApplicationMain.listViewLineHeight));

注意：AbsListView.LayoutParams，这里不能用android.view.ViewGroup.LayoutParams要不然会报类型不对哦。

 

2.ListView拖动时背景黑色的问题

A、通过布局属性来设定(ListView的属性中直接定义)

android:cacheColorHint=”#00000000″

B、在代码中直接设定

listView.setCacheColorHint(Color.TRANSPARENT);

listview.setAlwaysDrawnWithCacheEnabled(true);

3.点击popupWindow以外的区域popWindow自动消失方案

A、设置popupWindow.setFocusable(false);以后其它UI就可以获取焦点了，

在TOUNCH监听事件上进行DISMISS。代码如下：

@Override

public boolean onTouchEvent(MotionEvent event) {

// TODO Auto-generated method stub

if (popupWindow != null && popupWindow.isShowing()) {

popupWindow.dismiss();

popupWindow = null;

}

return super.onTouchEvent(event);

}

B、设置popupWindow参数如下：

popWindow.setBackgroundDrawable(new BitmapDrawable());

 

popWindow.setOutsideTouchable(true);