List of usage examples for android.widget RelativeLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:org.ciasaboark.tacere.activity.fragment.MainSettingsFragment.java
private void drawMediaWidgets() { RelativeLayout mediaBox = (RelativeLayout) rootView.findViewById(R.id.settings_mediaBox); mediaBox.setOnClickListener(new View.OnClickListener() { @Override// w ww.ja va 2 s . c om public void onClick(View v) { prefs.setMediaVolumeShouldSilence(!prefs.shouldMediaVolumeBeSilenced()); drawMediaWidgets(); } }); //the media volumes toggle SwitchCompat mediaSwitch = (SwitchCompat) rootView.findViewById(R.id.adjustMediaCheckBox); if (prefs.shouldMediaVolumeBeSilenced()) { mediaSwitch.setChecked(true); } else { mediaSwitch.setChecked(false); } }
From source file:org.ciasaboark.tacere.activity.fragment.MainSettingsFragment.java
private void drawCalendarWidgets() { ImageView calendarIcon = (ImageView) rootView.findViewById(R.id.calendar_icon); TextView calendarTV = (TextView) rootView.findViewById(R.id.calendar_text); RelativeLayout calendarBox = (RelativeLayout) rootView.findViewById(R.id.select_calendar_box); calendarBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .ja va2s . c o m*/ public void onClick(View view) { Authenticator authenticator = new Authenticator(context); if (authenticator.isAuthenticated()) { mListener.onSelectCalendarsSelectedListener(); } else { authenticator.showUpgradeDialog(); } } }); calendarBox.setClickable(true); }
From source file:de.petermoesenthin.alarming.MainActivity.java
/** * Sets up everything needed for the navigation drawer *///from w ww . ja va 2 s .co m private void setUpNavigationDrawer() { Log.d(DEBUG_TAG, "Setting up navigation drawer."); mDrawerTitles = getResources().getStringArray(R.array.nav_drawer_titles); mDrawerListView = (ListView) findViewById(R.id.drawer_listView); mTitle = mDrawerTitle = getTitle(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.material_yellow_dark)); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { setTitle(mTitle); } public void onDrawerOpened(View drawerView) { setTitle(mDrawerTitle); } }; mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerLayout.setDrawerListener(mDrawerToggle); List<DrawerItem> mDrawerItemList = new ArrayList<DrawerItem>(); for (int i = 0; i < mDrawerTitles.length; i++) { DrawerItem drawerItem = new DrawerItem(mDrawerImages[i], mDrawerTitles[i]); mDrawerItemList.add(drawerItem); } mDrawerListView.setAdapter(new DrawerItemArrayAdapter(this, R.layout.listitem_drawer, mDrawerItemList)); DrawerItemClickListener drawerItemClickListener = new DrawerItemClickListener(); mDrawerListView.setOnItemClickListener(drawerItemClickListener); RelativeLayout settingsButton = (RelativeLayout) findViewById(R.id.drawer_button_settings); settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showSettingsActivity(); mDrawerLayout.closeDrawers(); } }); RelativeLayout aboutButton = (RelativeLayout) findViewById(R.id.drawer_button_about); aboutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showAboutActivity(); mDrawerLayout.closeDrawers(); } }); }
From source file:org.worshipsongs.activity.CustomYoutubeBoxActivity.java
private void setRelativeLayout() { RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout_youtube_activity); relativeLayout.setOnClickListener(new View.OnClickListener() { @Override/*ww w .jav a 2s.co m*/ public void onClick(View v) { onBackPressed(); } }); }
From source file:ax.ha.it.smsalarm.activity.Splash.java
/** * Perform initialization of <code>Layout</code>'s, fetching {@link SharedPreferences}, setting up {@link View}'s, setting different * <code>Listener</code>'s and other things that's needed by this {@link Activity} in order for it to work. *//*from w w w. j av a2 s . c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Remove title on activity requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splash); // Report that the application was opened through the widget if (getIntent() != null && ACTION_REPORT_OPENED_THROUGH_WIDGET.equals(getIntent().getAction())) { GoogleAnalyticsHandler.sendEvent(EventCategory.USER_INTERFACE, EventAction.WIDGET_INTERACTION, WidgetProvider.OPEN_SMS_ALARM_LABEL); } // Text with correct version number versionTextView = (TextView) findViewById(R.id.splashVersion_tv); versionTextView.setText( String.format(getString(R.string.SPLASH_VERSION), getString(R.string.APPLICATION_VERSION))); // Fetch value from shared preferences, this is to decide if user has agreed user the user license before or not and to figure out if splash // screen should be shown or not endUserLicenseAgreed = (Boolean) prefHandler.fetchPrefs(PrefKey.SHARED_PREF, PrefKey.END_USER_LICENSE_AGREED, DataType.BOOLEAN, this, false); showSplashScreen = (Boolean) prefHandler.fetchPrefs(PrefKey.SHARED_PREF, PrefKey.SHOW_SPLASH_SCREEN_KEY, DataType.BOOLEAN, this, true); // Only set up onClickListener and start Runnable if user has agreed the end user license agreement if (endUserLicenseAgreed) { // Skip splash screen switch activity directly if (!showSplashScreen) { switchActivity(); } // Get a handle to the layout by finding it's id RelativeLayout splashRelativeLayout = (RelativeLayout) findViewById(R.id.splash_rl); // Create object that acts as listener to the sbStartView splashRelativeLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { switchActivity(); } }); // Initialize a handler object, used to put a thread to sleep, activity will be switched after thread has been a sleep for a given // time handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { switchActivity(); } }, delay); } else { // Else show dialog requesting for user to agree the license EulaDialog dialog = new EulaDialog(); dialog.show(getSupportFragmentManager(), EulaDialog.EULA_DIALOG_TAG); } }
From source file:com.lvfq.rabbit.fragment.SettingFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); RelativeLayout update = (RelativeLayout) view.findViewById(R.id.update_click); update.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja v a2s . c o m*/ public void onClick(View v) { if (isNetworkConnected()) { synchronized (canCheckUpdate) { if (canCheckUpdate) { canCheckUpdate = false; new UpdateBackgroundTask().execute(); } } } else { Toast.makeText(getActivity(), getString(R.string.nonetwork), Toast.LENGTH_SHORT).show(); } } }); RelativeLayout share = (RelativeLayout) view.findViewById(R.id.share_click); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isNetworkConnected()) { synchronized (canShare) { if (canShare) { canShare = false; new ShareBackgroundTask().execute(); } } } else { Toast.makeText(getActivity(), getString(R.string.nonetwork), Toast.LENGTH_SHORT).show(); } } }); RelativeLayout about = (RelativeLayout) view.findViewById(R.id.about_click); about.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), AboutActivity.class); getActivity().startActivity(intent); } }); }
From source file:org.ciasaboark.tacere.activity.fragment.MainSettingsFragment.java
private void drawRingerWidgets() { RelativeLayout ringerBox = (RelativeLayout) rootView.findViewById(R.id.settings_ringerBox); ringerBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2 s .co m*/ public void onClick(View v) { String[] ringerTypes = RingerType.names(); //we don't want ringer type UNDEFINED to be an option ArrayList<String> ringerList = new ArrayList<String>(); for (String type : ringerTypes) { if (!type.equalsIgnoreCase(RingerType.UNDEFINED.toString())) { type = type.charAt(0) + type.substring(1).toLowerCase(); ringerList.add(type); } } final String[] filteredRingerTypes = ringerList.toArray(new String[] {}); int previouslySelectedRinger = ringerList.indexOf(prefs.getRingerType().toString()); final AlertDialog alert = new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.Dialog)) .setTitle(R.string.settings_section_general_ringer) .setSingleChoiceItems(filteredRingerTypes, previouslySelectedRinger, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String selectedRingerString = filteredRingerTypes[which]; int selectedRingerValue = RingerType .getIntForStringValue(selectedRingerString); RingerType selectedRinger = RingerType.getTypeForInt(selectedRingerValue); prefs.setRingerType(selectedRinger); drawRingerWidgets(); dialog.dismiss(); } }) .create(); alert.show(); } }); //the ringer type description TextView ringerDescriptionTV = (TextView) rootView.findViewById(R.id.ringerTypeDescription); TextView ringerTV = (TextView) rootView.findViewById(R.id.settings_ringerTitle); Drawable icon; switch (prefs.getRingerType()) { case NORMAL: ringerDescriptionTV.setText(R.string.settings_section_general_ringer_normal); icon = getResources().getDrawable(R.drawable.ic_state_normal); break; case VIBRATE: ringerDescriptionTV.setText(R.string.settings_section_general_ringer_vibrate); icon = getResources().getDrawable(R.drawable.ic_state_vibrate); break; case SILENT: ringerDescriptionTV.setText(R.string.settings_section_general_ringer_silent); icon = getResources().getDrawable(R.drawable.ic_state_silent); break; case IGNORE: ringerDescriptionTV.setText(R.string.settings_section_general_ringer_ignore); icon = getResources().getDrawable(R.drawable.ic_state_ignore); break; default: throw new IllegalStateException("Saved default ringer is of unknown type: " + prefs.getRingerType()); } int iconColor = getResources().getColor(R.color.icon_tint); icon.mutate().setColorFilter(iconColor, PorterDuff.Mode.MULTIPLY); ringerDescriptionTV.setTextColor(getResources().getColor(R.color.text_color)); ringerTV.setTextColor(getResources().getColor(R.color.text_color)); ImageView ringerIcon = (ImageView) rootView.findViewById(R.id.settings_ringerIcon); ringerIcon.setImageDrawable(icon); }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawSilenceAllDayWidgets() { RelativeLayout allDayBox = (RelativeLayout) rootView.findViewById(R.id.advanced_settings_allday_box); allDayBox.setOnClickListener(new View.OnClickListener() { @Override/*w w w .j av a 2 s . c o m*/ public void onClick(View v) { prefs.setSilenceAllDayEvents(!prefs.shouldAllDayEventsSilence()); drawSilenceAllDayWidgets(); } }); // the silence all day state toggle CheckBox dayCB = (CheckBox) rootView.findViewById(R.id.silenceAllDayCheckBox); TextView dayTV = (TextView) rootView.findViewById(R.id.silenceAllDayDescription); if (prefs.shouldAllDayEventsSilence()) { dayCB.setChecked(true); dayTV.setText(R.string.advanced_settings_section_events_all_day_enabled); } else { dayCB.setChecked(false); dayTV.setText(R.string.advanced_settings_section_events_all_day_disabled); } }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawReportsWidget() { final CheckBox sendReportsCheckbox = (CheckBox) rootView .findViewById(R.id.advanced_settings_reports_checkbox); final CrashReportManager crashReportManager = new CrashReportManager(getActivity()); sendReportsCheckbox.setChecked(crashReportManager.isReportsEnabled()); TextView sendReportsDescription = (TextView) rootView .findViewById(R.id.advanced_settings_reports_description); sendReportsDescription.setText(crashReportManager.isReportsDisabled() ? R.string.advanced_settings_section_reports_description_disabled : R.string.advanced_settings_section_reports_description_enabled); RelativeLayout reportsBox = (RelativeLayout) rootView.findViewById(R.id.advanced_settings_reports_box); reportsBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2s .c o m*/ public void onClick(View v) { sendReportsCheckbox.performClick(); boolean willSendReports = sendReportsCheckbox.isChecked(); crashReportManager.setReportsEnabled(willSendReports); drawReportsWidget(); } }); }
From source file:org.ciasaboark.tacere.activity.fragment.AdvancedSettingsFragment.java
private void drawFreeTimeWidgets() { RelativeLayout freeTimeBox = (RelativeLayout) rootView.findViewById(R.id.advanced_settings_freetime_box); freeTimeBox.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j av a 2 s. c o m*/ public void onClick(View v) { prefs.setSilenceFreeTimeEvents(!prefs.shouldAvailableEventsSilence()); drawFreeTimeWidgets(); } }); // the silence free time state toggle CheckBox freeCB = (CheckBox) rootView.findViewById(R.id.silenceFreeTimeCheckBox); TextView freeTV = (TextView) rootView.findViewById(R.id.silenceFreeTimeDescription); if (prefs.shouldAvailableEventsSilence()) { freeCB.setChecked(true); freeTV.setText(R.string.advanced_settings_section_events_available_enabled); } else { freeCB.setChecked(false); freeTV.setText(R.string.advanced_settings_section_events_available_disabled); } }