내 동료했습니다. 우리는 번역하는 응용 프로그램을된 이+구속력이 있습니다. 필요가 있었을 시작하는 대화 상자에서 조각입니다. 나는 그것을 다음과 같다:
에 조각:
fragmentBinding.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// there's a bunch of code here
alertDialog.show();
}});
동료에게도 요구해야 하는 이렇게하려면:
Xml 파일에 우리가 쓰는 다음과 같다:
android:onClick="@{v -> viewModel.showDialog(context)}"
에서 뷰 모델:
fun showDialog(context: Context){
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// there's a bunch of code here
alertDialog.show();
}
저에게 알려주세요,하나는 올바른?