How to make area outside of custom dialog view unclickable?
- by portfoliobuilder
I created a custom dialog (no, this is not dialog object) from an image and some other views. The conflict I am having with this custom dialog (again, this is a layout) is that the area around it closes the custom dialog. Is there a way I can make the outside area unclickable?
I have tried wrapping the dialog view with a fullscreen frameLayout w/ transparent background, and then programmatically I set the frame attribute to setClickable(false).
framelayout.setClickable(false);
This does nothing. It still closes the dialog. Any other suggestions? Thank you in advance.
This is my code:
//used to disable background from closing the custom dialog
private FrameLayout fl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.layout_dialog);
btnContinue = (Button) findViewById(R.id.btnContinue);
btnContinue.setOnClickListener(this);
fl.setClickable(false); //background suppose to lock
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.Continue:
finish();
}
break;
}
}
I also have another class for broadcastReceiver
public class DialogManagerBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(IdeaPlayInterfaceApplication.isActivityVisible()){
Intent i=new Intent(context,CustomDialogActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
The idea is that this custom dialog is not called at a specific instance, it is called every set amount of time no matter what I am doing in the application.
I use an Intent and PendingIntent to repeatedly call this custom dialog over time. With something like this:
cancelAlarmNotificationMonitoring(context);
Calendar calendar = Calendar.getInstance();
Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
PendingIntent pintent = PendingIntent.getBroadcast(context, 0, intent, 0);
AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis()+ALARM_INTERVAL,ALARM_INTERVAL, pintent);
Hopefully this is more clear now.