【发布时间】:2019-08-12 05:25:59
【问题描述】:
我创建了我想在广播接收器中使用的自定义布局,但getLayoutInflater() 在接收器中不起作用
在 onreceiver 方法中我调用 startAlaram(context,intent)
private void startAlaram(final Context context, Intent intent) {
LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.custom_layout_notification, null);
AlertDialog.Builder builder=new AlertDialog.Builder(context,);
builder.setTitle("Get Reminder");
builder.setMessage("Alert ALert");
builder.setIcon(R.mipmap.ic_launcher_round);
builder.setView(view);
final AlertDialog dialog=builder.create();
TextView not_txt_title,not_txt_desc,not_txt_callfor,not_txt_name;
ImageView img1;
not_txt_title = view.findViewById( R.id.not_txt_title );
not_txt_desc = view.findViewById( R.id.not_txt_desc );
not_txt_callfor = view.findViewById( R.id.not_txt_callfor );
not_txt_name = view.findViewById( R.id.not_txt_name );
img1 = view.findViewById( R.id.img1);
not_txt_title.setText(rTitle);
not_txt_desc.setText(rDesc);
not_txt_callfor.setText(rCallFor);
not_txt_name.setText(rName);
dialog.show();
}
【问题讨论】:
标签: android-layout android-intent broadcastreceiver android-service receiver