Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
10
Help us understand the problem. What is going on with this article?
@matsuyoro

Android DialogFragmentで引数を扱う

More than 3 years have passed since last update.

ダイアログを呼び出す側で、引数を渡すところ

HogeFragment.java
// 〜省略
dialogFragment = new AlertDialogFragment();
Bundle args = new Bundle();
args.putInt("hoge_arg1",position); //引数
dialogFragment.setArguments(args);
dialogFragment.show(getActivity().getFragmentManager(),"dialog");
// 〜省略

ダイアログ表示に渡しした引数を取得するところ

AlertDialogFragment.java
// 〜省略
// アラートダイアログ
public static class AlertDialogFragment extends DialogFragment {

    private AlertDialog.Builder alert;

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        alert = new AlertDialog.Builder(getActivity());
        int hogeInt = getArguments().getInt("hoge_arg1");
// 〜省略
10
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
matsuyoro
げーむくりえいたー。 顔は濃いが存在の薄さに悩んでいる。 無敵のエンジニアに出会いたい。 書籍「仕事はたのしいかね」の、大きな事でも試してみればの精神に感銘を受けている。 好きな言葉:好きこそものの上手なれ / 楽は苦の種、苦は楽の種

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
10
Help us understand the problem. What is going on with this article?