アプリケーションに PopupMenu を追加したいと考えています。問題は、Android 2.3 でも動作することです。代わりに AlertDialog を使用することを提案する投稿をいくつか見つけましたが、私は PopupMenu を好みます;)
いくつかのアプリで見たことがあるので、この API レベルでも動作するはずだと思います (私の電話には 2.3.5 があり、正常に動作します)。
これを機能させる可能性はありますか?
アプリケーションに PopupMenu を追加したいと考えています。問題は、Android 2.3 でも動作することです。代わりに AlertDialog を使用することを提案する投稿をいくつか見つけましたが、私は PopupMenu を好みます;)
いくつかのアプリで見たことがあるので、この API レベルでも動作するはずだと思います (私の電話には 2.3.5 があり、正常に動作します)。
これを機能させる可能性はありますか?
次のように、サポート v7 をアプリケーションにインポートする必要があります:リソースを使用してライブラリを追加する
import android.support.v7.widget.PopupMenu;
それを使用してコードをコンパイルすると、ポップアップ メニューは android 2.2 以降と互換性があります。
PopupMenu は、電子メールを送信するメソッドでこれを試すことができ、必要に応じて xml を膨らませることができます。
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);
}
}
});