I like to add a PopupMenu to my application. The problem is that it should work on Android 2.3, too. I found some posts where people suggest to use AlertDialog as an alternative, but I prefer a PopupMenu ;)
I think it should work in this API-level, too because I've seen it in several apps (my phone has 2.3.5 and it work fine).
Is there any possibility to make this work?
You must import support v7 in your application same as follow: Adding libraries with resources
import android.support.v7.widget.PopupMenu;
Compile your code with that and then your popup menu is compatible for android 2.2 and above.
PopupMenu is possible you can try this in a method for sending an email and you can inflate your xml according to your own needs:
LayoutInflater inflater = (LayoutInflater)EEActionListDetail.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth()/2;
int height = display.getHeight()/2;
View pop = inflater.inflate(R.layout.popupemail,null,false);
pop.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED);
height = pop.getMeasuredHeight();
width = pop.getMeasuredWidth()+200;
pu = new PopupWindow(pop,width,height,true);
pu.showAtLocation(findViewById(R.id.ll3),Gravity.CENTER,1,1);
Button brnSend = (Button)pu.getContentView().findViewById(R.id.btnSend);
Button close = (Button)pu.getContentView().findViewById(R.id.close);
Subject = (EditText)pu.getContentView().findViewById(R.id.subject);
Message = (EditText)pu.getContentView().findViewById(R.id.message);
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pu.dismiss();
}
});
brnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for(int j=0;j<EmailArray.size();j++){
String EmailSent = EmailArray.get(j);
SendEmailALL(EmailSent);
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With