终于解决弹窗上图片按钮的点击
title_right_share = (ImageView) findViewById(R.id.title_right_share);
title_right_share.setOnClickListener(new OnClickListener() {@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
m(arg0);
}
});
}
private void m(View view) {
View contentView = View.inflate(getApplicationContext(),
R.layout.activity_popup, null);
pw = new PopupWindow(contentView, LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
pw.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
pw.setOutsideTouchable(true);
pw.setFocusable(true);
pw.setBackgroundDrawable(new PaintDrawable(Color.TRANSPARENT));
int[] location = new int[2];
view.getLocationInWindow(location);
pw.showAtLocation(view, Gravity.BOTTOM, 0, 0);
contentView.findViewById(R.id.iv_wxsession).setOnClickListener(this);
contentView.findViewById(R.id.iv_wxfriends).setOnClickListener(this);
contentView.findViewById(R.id.iv_qqsession).setOnClickListener(this);
contentView.findViewById(R.id.iv_phonemessage).setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.iv_wxsession:
Toast.makeText(getApplicationContext(), "微信好友分享", Toast.LENGTH_LONG)
.show();
wx(0);
break;
case R.id.iv_wxfriends:
Toast.makeText(getApplicationContext(), "朋友圈分享", Toast.LENGTH_LONG)
.show();
wx(1);
break;
case R.id.iv_qqsession:
Toast.makeText(getApplicationContext(), "QQ好友分享", Toast.LENGTH_LONG)
.show();
qq(v);
break;
case R.id.iv_phonemessage:
Toast.makeText(getApplicationContext(), "短信分享", Toast.LENGTH_LONG)
.show();
sendSMS("http://www.baidu.com");
break;
default:
break;
}
}