Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プログラムの実行時に一連のボタンを動的に作成したい.生成ボタンを作成するときにこれらのボタンを作成したいButton but=new Button(this);.別のボタンの OnClickListener 内で呼び出すことは可能ですか?
Button but=new Button(this);
はい - 必ず に変更new Button(this)してnew Button(mClass.this)ください。
new Button(this)
new Button(mClass.this)
はい..言うButton b = new Button(yourAct.this);..
Button b = new Button(yourAct.this);..
と言って親レイアウトに追加することを忘れないでくださいaddView(b)
addView(b)