List of usage examples for android.view Window addFlags
public void addFlags(int flags)
From source file:com.slushpupie.deskclock.DeskClock.java
private void setScreenLock(int keepOn, int screenBrightness, int buttonBrightness) { Window window = getWindow(); LayoutParams layoutParams = window.getAttributes(); Field fButtonBrightness = null; try {/*from ww w. j a v a 2 s. c om*/ fButtonBrightness = layoutParams.getClass().getField("buttonBrightness"); } catch (NoSuchFieldException e) { } if (keepOn > 0) { if (keepOn == 1) { // Auto-brightness layoutParams.screenBrightness = -1.0f; try { if (fButtonBrightness != null) fButtonBrightness.set(layoutParams, -1.0f); } catch (IllegalAccessException e) { } } else if (keepOn == 2) { // Manual brightness // Setting to 0 turns the screen off, so dont allow that if (prefsScreenBrightness <= 100 && prefsScreenBrightness > 0) layoutParams.screenBrightness = (prefsScreenBrightness / 100.0f); if (prefsScreenBrightness < 1) layoutParams.screenBrightness = 0.01f; try { if (fButtonBrightness != null && prefsButtonBrightness <= 100 && prefsButtonBrightness >= 0) fButtonBrightness.set(layoutParams, (prefsButtonBrightness / 100.0f)); } catch (IllegalAccessException e) { } } else { Log.e(LOG_TAG, "Unknown keepOn value!"); return; } window.setAttributes(layoutParams); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); } else { // Disable KEEP_SCREEN_ON try { if (fButtonBrightness != null) fButtonBrightness.set(layoutParams, -1.0f); } catch (IllegalAccessException e) { } layoutParams.screenBrightness = -1.0f; window.setAttributes(layoutParams); window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); } }
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
private void showOptionDialog(final AlertDialog dialog) { final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken(); if (windowToken == null) { return;/*from ww w .ja v a2 s . c om*/ } final Window window = dialog.getWindow(); final WindowManager.LayoutParams lp = window.getAttributes(); lp.token = windowToken; lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; window.setAttributes(lp); window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); mOptionsDialog = dialog; dialog.show(); }
From source file:com.android.calendar.EventInfoFragment.java
private void applyDialogParams() { Dialog dialog = getDialog();//from www . j a va 2 s. c om dialog.setCanceledOnTouchOutside(true); Window window = dialog.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); WindowManager.LayoutParams a = window.getAttributes(); a.dimAmount = .4f; a.width = mDialogWidth; a.height = mDialogHeight; // On tablets , do smart positioning of dialog // On phones , use the whole screen if (mX != -1 || mY != -1) { a.x = mX - mDialogWidth / 2; a.y = mY - mDialogHeight / 2; if (a.y < mMinTop) { a.y = mMinTop + DIALOG_TOP_MARGIN; } a.gravity = Gravity.LEFT | Gravity.TOP; } window.setAttributes(a); }
From source file:com.bookkos.bircle.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); _context = getApplicationContext();//from w w w.j av a 2 s . com _activity = this; currentTime = new Time("Asia/Tokyo"); // exceptionHandler = new ExceptionHandler(_context); // Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); // sharedPreference???, user_id?group_id?registration_id?? getUserData(); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // ?? WindowManager window_manager = getWindowManager(); Display display = window_manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point); displayWidth = point.x; displayHeight = point.y; displayInch = getInch(); // ??4??????? textSize = 17 * (displayInch / 4); actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); String title_text = ""; subGroupText = ""; groupText = groupName; if (displayInch < 4.7) { title_text = "<small><small><small>??: </small></small></small>"; resizeTitleSizeTooSmall(); } else if (displayInch >= 4.7 && displayInch < 5.5) { title_text = "<small><small>??: </small></small>"; resizeTitleSizeSmall(); } else if (displayInch >= 5.5 && displayInch < 6.5) { title_text = "<small>??: </small>"; resizeTitleSizeMiddle(); } else if (displayInch >= 6.5 && displayInch < 8) { title_text = "<small>??: </small>"; resizeTitleSizeLarge(); } else { title_text = "??: "; } String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>"; actionBar.setTitle(Html.fromHtml(modify_group_text)); Resources resources = _context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); titleBarHeight = resources.getDimensionPixelSize(resourceId); setContentView(R.layout.capture); returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view); returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help); returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView = (ImageView) findViewById(R.id.regist_help_view); registHelpView.setImageResource(R.drawable.regist_help); registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight); registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth, displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER)); registHelpView.setVisibility(View.GONE); leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); leftDrawer = (ListView) findViewById(R.id.left_drawer); textView = (TextView) findViewById(R.id.textView); modeText = (TextView) findViewById(R.id.mode_text); modeText.setTextColor(Color.rgb(56, 234, 123)); modeText.setTextSize(textSize); modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD); strokeColor = Color.rgb(56, 234, 123); borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton); registButton = (Button) findViewById(R.id.registButton); returnHistoryButton = (Button) findViewById(R.id.return_history_button); helpViewButton = (Button) findViewById(R.id.help_view_button); registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout); textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout); buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout); listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout); decisionButton = (Button) findViewById(R.id.decision_button); cancelButton = (Button) findViewById(R.id.cancel_button); shelfListView = (ListView) findViewById(R.id.shelf_list_view); tempTextView = (TextView) findViewById(R.id.temp_text_view); // bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this); bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout); bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout); bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout); bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view); bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view); bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button); registFlag = 0; int borrowReturnButton_width = displayWidth / 5 * 2; int borrowReturnButton_height = displayHeight / 10; int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2; int borrowReturnButton_y = displayHeight / 2 + titleBarHeight; borrowReturnButton.setTranslationX(borrowReturnButton_x); borrowReturnButton.setTranslationY(borrowReturnButton_y); borrowReturnButton .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height)); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); borrowReturnButton.setText("??\n"); borrowReturnButton.setTextSize(textSize * 7 / 10); borrowReturnButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 0; borrowReturnButton.setText("??\n"); borrowReturnButton.setEnabled(false); borrowReturnButton.setTextColor(Color.WHITE); borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123)); registButton.setText("?\n??"); registButton.setEnabled(true); registButton.setTextColor(Color.GRAY); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); modeText.setText("??"); modeText.setTextColor(Color.rgb(56, 234, 123)); returnBorrowHelpView.setVisibility(View.VISIBLE); registHelpView.setVisibility(View.GONE); strokeColor = Color.rgb(56, 234, 123); } }); int registButton_width = displayWidth / 5 * 2; int registButton_height = displayHeight / 10; int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2; int registButton_y = displayHeight / 2 + titleBarHeight; registButton.setTranslationX(registButton_x); registButton.setTranslationY(registButton_y); registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height)); registButton.setBackgroundColor(Color.argb(170, 21, 38, 45)); registButton.setTextColor(Color.GRAY); registButton.setTextSize(textSize * 7 / 10); registButton.setText("?\n??"); registButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { arrayList.clear(); registFlag = 1; borrowReturnButton.setText("??\n??"); borrowReturnButton.setEnabled(true); borrowReturnButton.setTextColor(Color.GRAY); borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16)); registButton.setText("?\n"); registButton.setEnabled(false); registButton.setTextColor(Color.WHITE); registButton.setBackgroundColor(Color.rgb(62, 162, 229)); modeText.setText("?"); modeText.setTextColor(Color.rgb(62, 162, 229)); returnBorrowHelpView.setVisibility(View.GONE); registHelpView.setVisibility(View.VISIBLE); strokeColor = Color.rgb(62, 162, 229); } }); returnHistoryButton.setText("????"); returnHistoryButton.setTextSize(textSize * 7 / 10); returnHistoryButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { leftDrawerLayout.openDrawer(Gravity.RIGHT); // animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight); } }); getReturnHistory(); getCurrentTime(); setHelpView(); setScanUnregisterBookView(); setBookRegistView(); arrayList = new ArrayList<String>(); tempRegistIsbn = ""; initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId; initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId; initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code="; initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code="; getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId; hasSurface = false; inactivityTimer = new InactivityTimer(this); bircleBeepManager = new BircleBeepManager(this); ambientLightManager = new AmbientLightManager(this); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); toastText = ""; }
From source file:com.eveningoutpost.dexdrip.Home.java
private void processIncomingBundle(Bundle bundle) { Log.d(TAG, "Processing incoming bundle"); if (bundle != null) { String receivedText = bundle.getString(WatchUpdaterService.WEARABLE_VOICE_PAYLOAD); if (receivedText != null) { voiceRecognitionText.setText(receivedText); voiceRecognitionText.setVisibility(View.VISIBLE); last_speech_time = JoH.ts(); naturalLanguageRecognition(receivedText); }/* w w w . ja v a2s . c o m*/ if (bundle.getString(WatchUpdaterService.WEARABLE_APPROVE_TREATMENT) != null) processAndApproveTreatment(); else if (bundle.getString(WatchUpdaterService.WEARABLE_CANCEL_TREATMENT) != null) cancelTreatment(); else if (bundle.getString(Home.START_SPEECH_RECOGNITION) != null) promptSpeechInput(); else if (bundle.getString(Home.START_TEXT_RECOGNITION) != null) promptTextInput_old(); else if (bundle.getString(Home.CREATE_TREATMENT_NOTE) != null) { try { showNoteTextInputDialog(null, Long.parseLong(bundle.getString(Home.CREATE_TREATMENT_NOTE)), JoH.tolerantParseDouble(bundle.getString(Home.CREATE_TREATMENT_NOTE + "2"))); } catch (NullPointerException e) { Log.d(TAG, "Got null point exception during CREATE_TREATMENT_NOTE Intent"); } } else if (bundle.getString(Home.HOME_FULL_WAKEUP) != null) { if (!JoH.isScreenOn()) { final int timeout = 60000; final PowerManager.WakeLock wl = JoH.getWakeLock("full-wakeup", timeout + 1000); final Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); final Timer t = new Timer(); t.schedule(new TimerTask() { @Override public void run() { JoH.releaseWakeLock(wl); finish(); } }, timeout); } else { Log.d(TAG, "Screen is already on so not turning on"); } } else if (bundle.getString(Home.GCM_RESOLUTION_ACTIVITY) != null) { GcmActivity.checkPlayServices(this, this); } else if (bundle.getString(Home.SNOOZE_CONFIRM_DIALOG) != null) { GcmActivity.sendSnoozeToRemoteWithConfirm(this); } } }
From source file:com.filemanager.free.activities.MainActivity.java
@SuppressLint("InflateParams") private void initialiseViews() { mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame); appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }/*from ww w .ja va 2 s .c om*/ if (displayImageOptions != null) { displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565).build(); } buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else { assert mDrawerLinear != null; mDrawerLinear.setBackgroundColor(Color.WHITE); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } View v = findViewById(R.id.fab_bg); if (theme1 == 1) { assert v != null; v.setBackgroundColor(Color.parseColor("#a6ffffff")); } assert v != null; v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) { assert divider != null; divider.setImageResource(R.color.divider); } else { assert divider != null; divider.setImageResource(R.color.divider_dark); } setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { assert settingsbutton != null; settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert settingsbutton != null; settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { assert appbutton != null; appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert appbutton != null; appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } //admob mAdView = (View) findViewById(R.id.ads); }
From source file:com.amaze.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }/*from w w w.j a v a 2 s . com*/ displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); if (theme1 == 1) v.setBackgroundColor(Color.parseColor("#a6ffffff")); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } }
From source file:com.igniva.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from ww w .jav a 2s . c o m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); mFabBackground = findViewById(R.id.fab_bg); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); /*if (theme1 != 1) v.setBackgroundColor(Color.parseColor("#a6ffffff"));*/ v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (theme1 == 1) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(getResources().getColor(android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(getResources().getColor(android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override//from w w w. j a v a2 s. c o m public boolean onLongClick(View v) { Intent intent; if (SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (getAppTheme().equals(AppTheme.DARK)) mDrawerLinear.setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background)); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); fabBgView = findViewById(R.id.fab_bg); if (getAppTheme().equals(AppTheme.DARK)) { fabBgView.setBackgroundResource(R.drawable.fab_shadow_dark); } fabBgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (getAppTheme().equals(AppTheme.LIGHT)) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsButton = findViewById(R.id.settingsbutton); if (getAppTheme().equals(AppTheme.DARK)) { settingsButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsButton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsButton.findViewById(R.id.settingtext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, PreferencesActivity.class); startActivity(in); finish(); } }); View appButton = findViewById(R.id.appbutton); if (getAppTheme().equals(AppTheme.DARK)) { appButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appButton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appButton.findViewById(R.id.apptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } appButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (getAppTheme().equals(AppTheme.DARK)) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(Utils.getColor(this, android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }