inflater = LayoutInflater.from(MainActivity.this)
Viewview=inflater.inflate(R.layout.activity_puopdialog,null)
final PopupWindow popup = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)
popup.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher))
popup.update()
popup.setOutsideTouchable(true)
popup.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
popup.dismiss()
return false
}
})
Button bu = (Button) findViewById(R.id.button3)
bu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "onclick success!", Toast.LENGTH_SHORT).show()
}
})
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//popup.showAsDropDown(v)
popup.showAtLocation(findViewById(R.id.button1),Gravity.RIGHT | Gravity.BOTTOM,0,0)
}
})
view.findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popup.dismiss()
}
})
}