基本信息
源码名称:android 自定义单选、多选对话框及popwindow窗口实例源码
源码大小:0.21M
文件格式:.zip
开发语言:Java
更新时间:2014-08-21
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
package com.geniuseoe2012.popwindow;
import java.util.List;
import com.geniuseoe2012.demo.R;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
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.ScrollView;
import android.widget.TextView;
public abstract class AbstractChoicePopWindow implements OnClickListener {
protected Context mContext;
protected View mParentView;
protected ScrollView mScrollView;
protected TextView mTVTitle;
protected Button mButtonOK;
protected Button mButtonCancel;
protected ListView mListView;
protected PopupWindow mPopupWindow;
protected List<String> mList;
private OnClickListener mOkListener;
public AbstractChoicePopWindow(Context context, View parentView,
List<String> list) {
mContext = context;
mParentView = parentView;
mList = list;
initView(mContext);
}
protected void initView(Context context) {
View view = LayoutInflater.from(context).inflate(
R.layout.popwindow_listview_layout, null);
mScrollView = (ScrollView) view.findViewById(R.id.scrollView);
mTVTitle = (TextView) view.findViewById(R.id.tvTitle);
mButtonOK = (Button) view.findViewById(R.id.btnOK);
mButtonOK.setOnClickListener(this);
mButtonCancel = (Button) view.findViewById(R.id.btnCancel);
mButtonCancel.setOnClickListener(this);
mPopupWindow = new PopupWindow(view, LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
mPopupWindow.setFocusable(true);
ColorDrawable dw = new ColorDrawable(0x00);
mPopupWindow.setBackgroundDrawable(dw);
mListView = (ListView) view.findViewById(R.id.listView);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btnOK:
onButtonOK(v);
break;
case R.id.btnCancel:
onButtonCancel(v);
break;
}
}
public void setOnOKButtonListener(OnClickListener onClickListener) {
mOkListener = onClickListener;
}
public void setTitle(String title) {
mTVTitle.setText(title);
}
public void show(boolean bShow) {
if (bShow) {
mScrollView.scrollTo(0, 0);
mPopupWindow.showAtLocation(mParentView, Gravity.TOP, 0, 0);
} else {
mPopupWindow.dismiss();
}
}
protected void onButtonOK(View v) {
show(false);
if (mOkListener != null) {
mOkListener.onClick(v);
}
}
protected void onButtonCancel(View v) {
show(false);
}
}