List of usage examples for android.widget LinearLayout setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.koushikdutta.superuser.FragmentLog.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //header = (LinearLayout) getActivity().findViewById(R.id.header); ImageView icon = (ImageView) getActivity().findViewById(R.id.icon); TextView title, subtitle, request, command; title = (TextView) getActivity().findViewById(R.id.title); subtitle = (TextView) getActivity().findViewById(R.id.subtitle); request = (TextView) getActivity().findViewById(R.id.request); command = (TextView) getActivity().findViewById(R.id.command); Intent intent = getActivity().getIntent(); if (intent != null) { Bundle bundle = intent.getBundleExtra("bundle"); if (bundle != null) { String cmd = bundle.getString("command"); int uid = bundle.getInt("uid", -1); int desiredUid = bundle.getInt("desiredUid", -1); if (uid != -1 && desiredUid != -1) up = SuDatabaseHelper.get(getContext(), uid, desiredUid, cmd); }/*w w w. j a va 2s . co m*/ } if (up != null) { String app = up.username; if (app == null || app.length() == 0) app = String.valueOf(up.uid); icon.setImageDrawable(Util.loadPackageIcon(getActivity(), up.packageName)); title.setTextColor(((ActivityLog) getActivity()).textToolbar); subtitle.setTextColor(((ActivityLog) getActivity()).textToolbar); request.setTextColor(((ActivityLog) getActivity()).textToolbar); command.setTextColor(((ActivityLog) getActivity()).textToolbar); title.setText(up.getName()); subtitle.setText(up.packageName + ", " + app); request.setText("Requested UID: " + up.desiredUid); command.setText( "Command: " + (TextUtils.isEmpty(up.command) ? getString(R.string.all_commands) : up.command)); //getListView().setSelector(android.R.color.transparent); } else { callback = (LogCallback) getActivity(); } LinearLayout logParent = (LinearLayout) getActivity().findViewById(R.id.log); LinearLayout notiParent = (LinearLayout) getActivity().findViewById(R.id.noti); int accent = ThemeStore.accentColor(getContext()); TintHelper.setTint(log, accent, false); TintHelper.setTint(notification, accent, false); if (up == null) { log.setChecked(Settings.getLogging(getActivity())); notiParent.setVisibility(View.GONE); notification.setChecked(false); } else { log.setChecked(up.logging); notification.setChecked(up.notification); } logParent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { log.setChecked(!log.isChecked()); } }); log.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (up == null) { Settings.setLogging(getActivity(), b); } else { up.logging = b; SuDatabaseHelper.setPolicy(getActivity(), up); } } }); notiParent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { notification.setChecked(!notification.isChecked()); } }); notification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (up == null) { } else { up.notification = notification.isChecked(); SuDatabaseHelper.setPolicy(getActivity(), up); } } }); load(); LocalBroadcastManager.getInstance(getContext()).registerReceiver(receiver, new IntentFilter(Common.INTENT_FILTER_LOG)); }
From source file:de.mrapp.android.preference.AbstractColorPickerPreference.java
@Override protected final View onCreateView(final ViewGroup parent) { View view = super.onCreateView(parent); LinearLayout widgetFrame = (LinearLayout) view.findViewById(android.R.id.widget_frame); widgetFrame.setVisibility(View.VISIBLE); previewView = new ImageView(getContext()); widgetFrame.addView(previewView, createPreviewLayoutParams()); adaptPreviewView();/*w w w . j a v a 2 s. c o m*/ return view; }
From source file:com.tinfoil.sms.sms.SendMessageActivity.java
public void setupKeyExchangeInterface() { LinearLayout et = (LinearLayout) findViewById(R.id.new_message_field); et.setVisibility(LinearLayout.INVISIBLE); LinearLayout layout = (LinearLayout) findViewById(R.id.key_exchange_field); layout.setVisibility(LinearLayout.VISIBLE); //Button exchange = (Button)findViewById(R.id.key_exchange); }
From source file:de.appetites.android.menuItemSearchAction.MenuItemSearchAction.java
private void createMenuItem(Menu menu, Drawable drawable, final LinearLayout list) { ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setLayoutParams(layoutParams);/*from w w w. j a v a 2 s . c o m*/ setHint(R.string.menu_item_search_action_hint); searchItem = menu.add(R.string.menu_item_search_action_menu_text).setIcon(drawable); searchItem.setActionView(this).setTitle("Search"); searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { // open keyboard list.setVisibility(View.VISIBLE); MenuItemSearchAction.this.setText(""); MenuItemSearchAction.this.requestFocus(); MenuItemSearchAction.this.postDelayed(new Runnable() { @Override public void run() { InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } }, 200); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { // close keyboard list.setVisibility(View.GONE); InputMethodManager imm = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(MenuItemSearchAction.this.getWindowToken(), 0); return true; } }); setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { // perform Search searchPerformListener.performSearch(MenuItemSearchAction.this.getText().toString()); searchItem.collapseActionView(); return true; } return false; } }); }
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showMetar(Intent intent) { if (getActivity() == null) { // Not ready to do this yet return;/*from ww w. j av a 2 s .c o m*/ } Metar metar = (Metar) intent.getSerializableExtra(NoaaService.RESULT); if (metar == null) { return; } View detail = findViewById(R.id.wx_detail_layout); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); layout.removeAllViews(); TextView tv = (TextView) findViewById(R.id.status_msg); if (!metar.isValid) { tv.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); tv.setText("Unable to get METAR for this location"); addRow(layout, "This could be due to the following reasons:"); addBulletedRow(layout, "Network connection is not available"); addBulletedRow(layout, "ADDS does not publish METAR for this station"); addBulletedRow(layout, "Station is currently out of service"); addBulletedRow(layout, "Station has not updated the METAR for more than 3 hours"); detail.setVisibility(View.GONE); stopRefreshAnimation(); setFragmentContentShown(true); return; } else { tv.setText(""); tv.setVisibility(View.GONE); layout.setVisibility(View.GONE); detail.setVisibility(View.VISIBLE); } tv = (TextView) findViewById(R.id.wx_station_info2); WxUtils.setFlightCategoryDrawable(tv, metar.flightCategory); tv = (TextView) findViewById(R.id.wx_age); tv.setText(TimeUtils.formatElapsedTime(metar.observationTime)); // Raw Text tv = (TextView) findViewById(R.id.wx_raw_metar); tv.setText(metar.rawText); // Winds tv = (TextView) findViewById(R.id.wx_wind_label); layout = (LinearLayout) findViewById(R.id.wx_wind_layout); layout.removeAllViews(); int visibility = View.GONE; if (metar.windSpeedKnots < Integer.MAX_VALUE) { showWindInfo(layout, metar); visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Visibility tv = (TextView) findViewById(R.id.wx_vis_label); layout = (LinearLayout) findViewById(R.id.wx_vis_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.visibilitySM < Float.MAX_VALUE) { if (metar.flags.contains(Flags.AutoReport) && metar.visibilitySM == 10) { addRow(layout, "10+ statute miles horizontal"); } else { NumberFormat decimal2 = NumberFormat.getNumberInstance(); decimal2.setMaximumFractionDigits(2); decimal2.setMinimumFractionDigits(0); addRow(layout, String.format("%s statute miles horizontal", FormatUtils.formatNumber(metar.visibilitySM))); } if (metar.vertVisibilityFeet < Integer.MAX_VALUE) { addRow(layout, String.format("%s vertical", FormatUtils.formatFeetAgl(metar.vertVisibilityFeet))); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Weather layout = (LinearLayout) findViewById(R.id.wx_weather_layout); layout.removeAllViews(); for (WxSymbol wx : metar.wxList) { addWeatherRow(layout, wx, metar.flightCategory); } // Sky Conditions tv = (TextView) findViewById(R.id.wx_sky_cond_label); layout = (LinearLayout) findViewById(R.id.wx_sky_cond_layout); layout.removeAllViews(); visibility = View.GONE; if (!metar.skyConditions.isEmpty()) { for (SkyCondition sky : metar.skyConditions) { addSkyConditionRow(layout, sky, metar.flightCategory); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Temperature tv = (TextView) findViewById(R.id.wx_temp_label); layout = (LinearLayout) findViewById(R.id.wx_temp_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.tempCelsius < Float.MAX_VALUE && metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Temperature", FormatUtils.formatTemperature(metar.tempCelsius)); if (metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Dew point", FormatUtils.formatTemperature(metar.dewpointCelsius)); addRow(layout, "Relative humidity", String.format("%.0f%%", WxUtils.getRelativeHumidity(metar))); long denAlt = WxUtils.getDensityAltitude(metar); if (denAlt > mElevation) { addRow(layout, "Density altitude", FormatUtils.formatFeet(denAlt)); } } else { addRow(layout, "Dew point", "n/a"); } if (metar.maxTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour maximum", FormatUtils.formatTemperature(metar.maxTemp6HrCentigrade)); } if (metar.minTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour minimum", FormatUtils.formatTemperature(metar.minTemp6HrCentigrade)); } if (metar.maxTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour maximum", FormatUtils.formatTemperature(metar.maxTemp24HrCentigrade)); } if (metar.minTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour minimum", FormatUtils.formatTemperature(metar.minTemp24HrCentigrade)); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Pressure tv = (TextView) findViewById(R.id.wx_pressure_label); layout = (LinearLayout) findViewById(R.id.wx_pressure_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.altimeterHg < Float.MAX_VALUE) { addRow(layout, "Altimeter", FormatUtils.formatAltimeter(metar.altimeterHg)); if (metar.seaLevelPressureMb < Float.MAX_VALUE) { addRow(layout, "Sea level pressure", String.format("%s mb", FormatUtils.formatNumber(metar.seaLevelPressureMb))); } long presAlt = WxUtils.getPressureAltitude(metar); if (presAlt > mElevation) { addRow(layout, "Pressure altitude", FormatUtils.formatFeet(presAlt)); } if (metar.pressureTend3HrMb < Float.MAX_VALUE) { addRow(layout, "3-hour tendency", String.format("%+.2f mb", metar.pressureTend3HrMb)); } if (metar.presfr) { addRow(layout, "Pressure falling rapidly"); } if (metar.presrr) { addRow(layout, "Pressure rising rapidly"); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Precipitation tv = (TextView) findViewById(R.id.wx_precip_label); layout = (LinearLayout) findViewById(R.id.wx_precip_layout); layout.removeAllViews(); if (metar.precipInches < Float.MAX_VALUE) { addRow(layout, "1-hour precipitation", String.format("%.2f\"", metar.precipInches)); } if (metar.precip3HrInches < Float.MAX_VALUE) { addRow(layout, "3-hour precipitation", String.format("%.2f\"", metar.precip3HrInches)); } if (metar.precip6HrInches < Float.MAX_VALUE) { addRow(layout, "6-hour precipitation", String.format("%.2f\"", metar.precip6HrInches)); } if (metar.precip24HrInches < Float.MAX_VALUE) { addRow(layout, "24-hour precipitation", String.format("%.2f\"", metar.precip24HrInches)); } if (metar.snowInches < Float.MAX_VALUE) { addRow(layout, "Snow depth", String.format("%.0f\"", metar.snowInches)); } if (metar.snincr) { addRow(layout, "Snow is increasing rapidly"); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Remarks tv = (TextView) findViewById(R.id.wx_remarks_label); layout = (LinearLayout) findViewById(R.id.wx_remarks_layout); layout.removeAllViews(); for (Flags flag : metar.flags) { addBulletedRow(layout, flag.toString()); } for (String remark : mRemarks) { addBulletedRow(layout, remark); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Fetch time tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), metar.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }
From source file:org.egov.android.view.activity.RegisterActivity.java
@SuppressLint("NewApi") private void _hidePasswordMessage() { final LinearLayout viewpwd = (LinearLayout) findViewById(R.id.passwordmsgcontainer); if (AndroidLibrary.getInstance().getSession().getInt("api_level", 0) >= 12) { viewpwd.animate().translationY(0).alpha(0.0f).setListener(new AnimatorListenerAdapter() { @Override//from w w w . ja va2 s. c o m public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); viewpwd.setVisibility(View.GONE); Editor editor = sharedpreferences.edit(); editor.putBoolean("register.pwdinfo", true); editor.commit(); } }); } else { viewpwd.setVisibility(View.GONE); } }
From source file:de.da_sense.moses.client.AvailableFragment.java
/** * Controls what to do and what to show in case we get a non empty list of * applications.//from w w w . ja va 2s . com * * @param applications * list of the applications to show */ private void initControlsNormalList(List<ExternalApplication> applications) { if (isVisible()) { // show a "normal" non-empty list LinearLayout emptylistCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_emptylistLayout); if (emptylistCtrls != null) emptylistCtrls.setVisibility(View.GONE); LinearLayout apkListCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_mainListLayout); if (apkListCtrls != null) apkListCtrls.setVisibility(View.VISIBLE); // set last layout setLastSetLayout(LayoutState.NORMAL_LIST); // and show the applications in the list populateList(applications); } }
From source file:com.metinkale.prayerapp.vakit.fragments.NotificationPrefs.java
private void initEarly(int switchId, int textId, int expandId, final Vakit vakit) { final SwitchCompat sw = (SwitchCompat) mView.findViewById(switchId); final LinearLayout expand = (LinearLayout) mView.findViewById(expandId); sw.setChecked(mTimes.isEarlyNotificationActive(vakit)); sw.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*w w w. j a v a 2 s . c o m*/ public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mTimes.setEarlyNotificationActive(vakit, b); if (!b && expand.getVisibility() == View.VISIBLE) { expand.setVisibility(View.GONE); } } }); View title = (View) mView.findViewById(textId).getParent(); title.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!BuildConfig.DEBUG) { return false; } mTestAlarm = true; Times.Alarm a = new Times.Alarm(); a.time = System.currentTimeMillis() + (5 * 1000); a.city = mTimes.getID(); a.early = true; a.vakit = vakit; AlarmReceiver.setAlarm(getActivity(), a); Toast.makeText(App.getContext(), "Will play within 5 seconds", Toast.LENGTH_LONG).show(); return true; } }); title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (sw.isChecked()) { expand.setVisibility((expand.getVisibility() == View.VISIBLE) ? View.GONE : View.VISIBLE); } else { Toast.makeText(getActivity(), R.string.activateForMorePrefs, Toast.LENGTH_LONG).show(); } } }); PrefsView sound = (PrefsView) expand.findViewById(R.id.sound); sound.setVakit(vakit); sound.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getEarlySound(vakit); } @Override public void setValue(Object obj) { mTimes.setEarlySound(vakit, (String) obj); } }); PrefsView vibr = (PrefsView) expand.findViewById(R.id.vibration); vibr.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.hasEarlyVibration(vakit); } @Override public void setValue(Object obj) { mTimes.setEarlyVibration(vakit, (boolean) obj); } }); PrefsView silenter = (PrefsView) expand.findViewById(R.id.silenter); silenter.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getEarlySilenterDuration(vakit); } @Override public void setValue(Object obj) { mTimes.setEarlySilenterDuration(vakit, (int) obj); } }); PrefsView dua = (PrefsView) expand.findViewById(R.id.dua); dua.setVisibility(View.GONE); PrefsView time = (PrefsView) expand.findViewById(R.id.time); time.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getEarlyTime(vakit); } @Override public void setValue(Object obj) { mTimes.setEarlyTime(vakit, (int) obj); } }); }
From source file:com.metinkale.prayerapp.vakit.fragments.NotificationPrefs.java
private void initMain(int switchId, int textId, int expandId, final Vakit vakit) { final SwitchCompat sw = (SwitchCompat) mView.findViewById(switchId); final LinearLayout expand = (LinearLayout) mView.findViewById(expandId); sw.setChecked(mTimes.isNotificationActive(vakit)); sw.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override/*from ww w . ja v a2s.co m*/ public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mTimes.setNotificationActive(vakit, b); if (!b && expand.getVisibility() == View.VISIBLE) { expand.setVisibility(View.GONE); } } }); View title = (View) mView.findViewById(textId).getParent(); title.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!BuildConfig.DEBUG) { return false; } mTestAlarm = true; Times.Alarm a = new Times.Alarm(); a.time = System.currentTimeMillis() + (5 * 1000); a.city = mTimes.getID(); a.vakit = vakit; AlarmReceiver.setAlarm(getActivity(), a); Toast.makeText(App.getContext(), "Will play within 5 seconds", Toast.LENGTH_LONG).show(); return true; } }); title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (sw.isChecked()) { expand.setVisibility(expand.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); } else { Toast.makeText(getActivity(), R.string.activateForMorePrefs, Toast.LENGTH_LONG).show(); } } }); PrefsView sound = (PrefsView) expand.findViewById(R.id.sound); sound.setVakit(vakit); sound.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getSound(vakit); } @Override public void setValue(Object obj) { mTimes.setSound(vakit, (String) obj); } }); PrefsView vibr = (PrefsView) expand.findViewById(R.id.vibration); vibr.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.hasVibration(vakit); } @Override public void setValue(Object obj) { mTimes.setVibration(vakit, (boolean) obj); } }); PrefsView silenter = (PrefsView) expand.findViewById(R.id.silenter); silenter.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getSilenterDuration(vakit); } @Override public void setValue(Object obj) { mTimes.setSilenterDuration(vakit, (int) obj); } }); PrefsView dua = (PrefsView) expand.findViewById(R.id.dua); dua.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getDua(vakit); } @Override public void setValue(Object obj) { mTimes.setDua(vakit, (String) obj); } }); PrefsView time = (PrefsView) expand.findViewById(R.id.time); if (vakit == Vakit.SABAH) { time.setTag("SabahTime"); time.setPrefFunctions(new PrefsView.PrefsFunctions() { @Override public Object getValue() { return mTimes.getSabahTime() * (mTimes.isAfterImsak() ? -1 : 1); } @Override public void setValue(Object obj) { int time = (int) obj; mTimes.setSabahTime(Math.abs(time)); mTimes.setAfterImsak(time < 0); } }); } else { time.setVisibility(View.GONE); } }