2016년 5월 17일 화요일

android R.id 의 값 동적으로 가져오기

String buttonID = "resolution_btn_" + idx ; 
        int resID = getResources().getIdentifier(buttonID, "id", getActivity().getPackageName()); 
        Button view = ((Button) mRootView.findViewById(resID)); 

실제 id 값들 
{R.id.resolution_btn_0, R.id.resolution_btn_1, R.id.resolution_btn_2, R.id.resolution_btn_3, R.id.resolution_btn_4, R.id.resolution_btn_5, R.id.resolution_btn_125}

댓글 없음:

댓글 쓰기