rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

android AlertDialog内にinflateしたLayout内のViewへのアクセス

android AlertDialog内にinflateしたLayout内のViewへのアクセス

2018 Jan. 21.

Viewへのアスセスにはそれが所属するLayoutを指定する。


LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View myLayout = inflater.inflate(R.layout.my_layout, null);
TextView myTextView = (TextView)myLayout.findViewById(R.id.my_text_view);
myTextView.setText("Hello.");