package xmu.zgy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.SimpleAdapter;
/**
*
* @author yulongfei
* @blog blog.csdn.net/zgyulongfei
*
*/
public class PopupWindowDemoActivity extends Activity {
private Button button;
private PopupWindow popupWindow;
private ListView listView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initControls();
}
private void initControls() {
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.listview_demo, null);
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.item,
new String[] { "text" },
new int[] { R.id.item });
listView = (ListView) view.findViewById(R.id.listview);
listView.setAdapter(adapter);
//自适配长、框设置
popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg));
popupWindow.setOutsideTouchable(true);
popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
popupWindow.update();
popupWindow.setTouchable(true);
popupWindow.setFocusable(true);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!popupWindow.isShowing()) {
popupWindow.showAsDropDown(button, 0, 0);
}
}
});
}
private List<Map<String, String>> getData() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("text", "中国");
list.add(map);
map = new HashMap<String, String>();
map.put("text", "加油");
list.add(map);
map = new HashMap<String, String>();
map.put("text", "钓鱼岛是中国的");
list.add(map);
map = new HashMap<String, String>();
map.put("text", "!!");
list.add(map);
return list;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
popupWindow显示listview后,自适配
共26个文件
class:8个
xml:5个
png:4个
5星 · 超过95%的资源 需积分: 15 458 下载量 140 浏览量
2012-09-12
23:43:44
上传
评论 3
收藏 48KB RAR 举报
温馨提示
在popupwindow中显示listview的自适配方式。 blog.csdn.net/zgyulongfei
资源推荐
资源详情
资源评论
收起资源包目录
PopupWindowDemo.rar (26个子文件)
PopupWindowDemo
.project 851B
default.properties 362B
bin
PopupWindowDemo.apk 17KB
xmu
zgy
R$string.class 394B
PopupWindowDemoActivity.class 3KB
R$layout.class 426B
R$drawable.class 393B
R.class 454B
PopupWindowDemoActivity$1.class 1KB
R$attr.class 307B
R$id.class 411B
resources.ap_ 13KB
classes.dex 5KB
proguard.cfg 1KB
AndroidManifest.xml 684B
src
xmu
zgy
PopupWindowDemoActivity.java 2KB
res
values
strings.xml 189B
layout
listview_demo.xml 503B
item.xml 378B
main.xml 386B
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
drawable
bg.png 834B
drawable-mdpi
icon.png 3KB
.classpath 280B
gen
xmu
zgy
R.java 985B
assets
共 26 条
- 1
似乎已不再年轻
- 粉丝: 542
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页