List of usage examples for android.widget LinearLayout getChildAt
public View getChildAt(int index)
From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java
private void headerScroll(float progress) { /*// w ww. java 2 s. co m * How progress works: * |------|------|------| * 0 1/3 2/3 1 * * To calculate the "progress" of a particular tab, one can use this * formula: * * <tab beginning with 0> * (1 / (total tabs - 1)) */ LinearLayout hl = (LinearLayout) getActivity().findViewById(R.id.header_layout); if (hl == null) return; int width = hl.getChildAt(0).getWidth(); int x = (int) (progress * width); mHeader.smoothScrollTo(x, 0); }
From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java
private void headerHighlightTab(int existingPosition, int newPosition) { LinearLayout hl = (LinearLayout) getActivity().findViewById(R.id.header_layout); if (hl == null) return;//from ww w . ja va 2 s. c o m TextView oldView = (TextView) hl.getChildAt(existingPosition); if (oldView != null) oldView.setTextColor(Color.GRAY); TextView newView = (TextView) hl.getChildAt(newPosition); if (newView != null) newView.setTextColor(Color.WHITE); }
From source file:me.tipi.kiosk.ui.fragments.IdentityFragment.java
/** * Style date picker./*from w ww.ja v a2 s.com*/ * * @param datePicker the date picker */ private void styleDatePicker(DatePicker datePicker) { datePicker.setCalendarViewShown(false); datePicker.setSpinnersShown(true); LinearLayout llFirst = (LinearLayout) datePicker.getChildAt(0); LinearLayout llSecond = (LinearLayout) llFirst.getChildAt(0); for (int i = 0; i < llSecond.getChildCount(); i++) { NumberPicker picker = (NumberPicker) llSecond.getChildAt(i); // NumberPickers in llSecond Field[] pickerFields = NumberPicker.class.getDeclaredFields(); for (Field pf : pickerFields) { if (pf.getName().equals("mSelectionDivider")) { pf.setAccessible(true); try { pf.set(picker, ContextCompat.getDrawable(getActivity(), R.drawable.picker_divider)); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } break; } } } }
From source file:com.materialdesign.view.tab.TabLayout.java
/** * ?tab//w w w. j a v a 2 s .co m * * @param view tabView * @param selector ? */ private void tabViewSelector(View view, boolean selector) { LinearLayout layout = null; if (LinearLayout.class.isInstance(view)) { layout = (LinearLayout) view; } for (int y = 0; y < layout.getChildCount(); y++) { layout.getChildAt(y).setSelected(selector); } }
From source file:cn.com.incito.driver.UI.detailDialog.PCCFragmentActivity.java
/** * //from w w w . ja v a2s .c o m */ private void notifySelectedCities() { LinearLayout selectedLayout = (LinearLayout) findViewById(R.id.selected_cities_linearlayout); for (int i = 0; i < selectedLayout.getChildCount(); i++) { Button selectedBtn = (Button) selectedLayout.getChildAt(i); if (i < selectedCities.size() && selectedCities.get(i) != null) { selectedBtn.setVisibility(View.VISIBLE); ModelSelectedCity selectedCity = selectedCities.get(i); if (selectedCity.country != null && !TextUtils.isEmpty(selectedCity.country)) { selectedBtn.setText(selectedCity.country); } else if (selectedCity.city != null && !TextUtils.isEmpty(selectedCity.city)) { selectedBtn.setText(selectedCity.city); } else { selectedBtn.setText(selectedCity.province); } } else { selectedBtn.setVisibility(View.GONE); } } }
From source file:com.todoroo.astrid.activity.TaskEditFragment.java
public static void setViewHeightBasedOnChildren(LinearLayout view) { int totalHeight = 0; int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(), MeasureSpec.AT_MOST); for (int i = 0; i < view.getChildCount(); i++) { View listItem = view.getChildAt(i); listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += listItem.getMeasuredHeight(); }//from ww w.j a va 2s . c o m ViewGroup.LayoutParams params = view.getLayoutParams(); if (params == null) return; params.height = totalHeight; view.setLayoutParams(params); view.requestLayout(); }
From source file:cn.com.incito.driver.UI.detailDialog.PCCFragmentActivity.java
/** * ??/* w ww.j av a2 s. c o m*/ */ private void setSelectedBtnsListener() { LinearLayout selectedLayout = (LinearLayout) findViewById(R.id.selected_cities_linearlayout); for (int i = 0; i < selectedLayout.getChildCount(); i++) { Button selectedBtn = (Button) selectedLayout.getChildAt(i); selectedBtn.setTag(i); selectedBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int indext = (Integer) v.getTag(); selectedCities.remove(indext); notifySelectedCities(); pager.setCurrentItem(0); cityFragment.clearDatas(); countryFragment.clearDatas(); if (selectedCities.size() > 0) { mCurrentSelected = selectedCities.size() - 1; } else { mCurrentSelected = -1; } } }); } }
From source file:eu.power_switch.gui.fragment.configure_receiver.ConfigureReceiverDialogPage3SetupFragment.java
private ArrayList<UniversalButton> getCurrentUniversalButtons() { ArrayList<UniversalButton> buttons = new ArrayList<>(); for (int i = 0; i < buttonsList.getChildCount(); i++) { LinearLayout universalButtonLayout = (LinearLayout) buttonsList.getChildAt(i); LinearLayout nameLayout = (LinearLayout) universalButtonLayout.getChildAt(0); AppCompatEditText nameEditText = (AppCompatEditText) nameLayout.getChildAt(0); AppCompatEditText signalEditText = (AppCompatEditText) universalButtonLayout.getChildAt(1); buttons.add(new UniversalButton(null, nameEditText.getText().toString(), null, signalEditText.getText().toString())); }// ww w . j av a 2 s. c o m return buttons; }
From source file:com.pdftron.pdf.controls.AddPageDialogFragment.java
private void setActiveMode(PageType type) { mCurrentPageType = type;/* www. j a v a 2s . c o m*/ for (PageType pType : PageType.values()) { LinearLayout btnLayout = mViewPagerChildren.get(pType.ordinal()); ImageView imgView = (ImageView) btnLayout.getChildAt(0); switch (pType) { case Blank: imgView.setImageDrawable(getResources().getDrawable( (type == pType) ? R.drawable.blankpage_selected : R.drawable.blankpage_regular)); break; case Lined: imgView.setImageDrawable(getResources().getDrawable( (type == pType) ? R.drawable.linedpage_selected : R.drawable.linedpage_regular)); break; case Graph: imgView.setImageDrawable(getResources().getDrawable( (type == pType) ? R.drawable.graphpage2_selected : R.drawable.graphpage2_regular)); break; case Grid: imgView.setImageDrawable(getResources().getDrawable( (type == pType) ? R.drawable.graphpage_selected : R.drawable.graphpage_regular)); break; case Music: imgView.setImageDrawable(getResources().getDrawable( (type == pType) ? R.drawable.musicpage_selected : R.drawable.musicpage_regular)); break; } } }
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.detail_help) { Intent detailIntent = new Intent(getActivity(), HelpActivity.class); startActivity(detailIntent);/*from ww w. ja v a 2s . com*/ } else if (id == R.id.qr_code) { try { Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); // "PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { // This is where the play store is called if the app is not installed Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); } } else if (id == R.id.save) { InetAddressValidator ipValidate = new InetAddressValidator(); Context context = getActivity(); // We know we will use a toast, so set it up now int duration = Toast.LENGTH_LONG; CharSequence text = "Saving config"; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); //The following is all input validation try { if ((Integer.parseInt(txt_server_port.getText().toString()) > 0) && (Integer.parseInt(txt_server_port.getText().toString()) < 65535)) { // check for valid port txt_server_port.setText(String.valueOf(Integer.parseInt(txt_server_port.getText().toString()))); } else { txt_server_port.setText(String.valueOf(62201)); } } catch (NumberFormatException ex) { txt_server_port.setText(String.valueOf(62201)); } if (txt_NickName.getText().toString().equalsIgnoreCase("")) { // Need to create a new Nick toast.setText("You Must choose a unique Nickname."); // choosing a used nick will just overwrite it. So really toast.show(); } else if (chkb64hmac.isChecked() && txt_HMAC.getText().toString().length() % 4 != 0) { // base64 must have a multiple of 4 length toast.setText("Hmac is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64hmac.isChecked() && !(txt_HMAC.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Hmac is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (chkb64key.isChecked() && txt_KEY.getText().toString().length() % 4 != 0) { toast.setText("Key is not a valid Base64, not a multiple of 4."); toast.show(); } else if (chkb64key.isChecked() && !(txt_KEY.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters toast.setText("Key is not a valid Base64, Contains disallowed characters."); toast.show(); } else if (!(txt_ports.getText().toString().matches("tcp/\\d.*") || txt_ports.getText().toString().matches("udp/\\d.*"))) { toast.setText("Access ports must be in the form of 'tcp/22'"); toast.show(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Allow IP") && (!ipValidate.isValid(txt_allowIP.getText().toString()))) { //Have to have a valid ip to allow, if using allow ip toast.setText("You Must supply a valid IP address to 'Allow IP'."); toast.show(); } else if (!ipValidate.isValid(txt_server_ip.getText().toString()) && !DomainValidator.getInstance().isValid(txt_server_ip.getText().toString())) { // check server entry. Must be a valid url or ip. toast.setText("You Must supply a valid server address."); toast.show(); } else if (txt_KEY.getText().toString().equalsIgnoreCase("")) { toast.setText("You Must supply a Rijndael key."); toast.show(); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh") && juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()) == null) { toast.setText("A connection must be saved in Juicessh before being used here."); toast.show(); // //end input validation, actual saving below } else { toast.show(); if (configtype.equalsIgnoreCase("Open Port")) { config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.PORTS = ""; config.SERVER_TIMEOUT = ""; } if (configtype.equalsIgnoreCase("Nat Access")) { config.NAT_IP = txt_nat_ip.getText().toString(); config.NAT_PORT = txt_nat_port.getText().toString(); config.PORTS = txt_ports.getText().toString(); config.SERVER_TIMEOUT = txt_server_time.getText().toString(); } else { config.NAT_IP = ""; config.NAT_PORT = ""; } if (configtype.equalsIgnoreCase("Server Command")) { config.SERVER_CMD = txt_server_cmd.getText().toString(); } else { config.SERVER_CMD = ""; } if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Resolve IP")) { config.ACCESS_IP = spn_allowip.getSelectedItem().toString(); } else if (spn_allowip.getSelectedItem().toString().equalsIgnoreCase("Source IP")) { config.ACCESS_IP = "0.0.0.0"; } else { config.ACCESS_IP = txt_allowIP.getText().toString(); } config.NICK_NAME = txt_NickName.getText().toString(); config.SERVER_IP = txt_server_ip.getText().toString(); config.SERVER_PORT = txt_server_port.getText().toString(); config.SSH_CMD = ""; if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("SSH Uri")) { config.SSH_CMD = txt_ssh_cmd.getText().toString(); config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); } else if (spn_ssh.getSelectedItem().toString().equalsIgnoreCase("Juicessh")) { config.SSH_CMD = "juice:" + juice_adapt.getConnectionName(spn_juice.getSelectedItemPosition()); config.juice_uuid = juice_adapt.getConnectionId(spn_juice.getSelectedItemPosition()); } else { config.juice_uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); config.SSH_CMD = ""; } config.KEY = txt_KEY.getText().toString(); //key config.KEY_BASE64 = chkb64key.isChecked(); //is key b64 config.HMAC = txt_HMAC.getText().toString(); // hmac key config.HMAC_BASE64 = chkb64hmac.isChecked(); //is hmac base64 mydb.updateConfig(context, config); //this updates the list for one panel mode Activity activity = getActivity(); if (activity instanceof ConfigListActivity) { ConfigListActivity myactivity = (ConfigListActivity) activity; myactivity.onItemSaved(); } else { ConfigDetailActivity myactivity = (ConfigDetailActivity) activity; myactivity.onBackPressed(); } } } else { return false; } return super.onOptionsItemSelected(item); }