List of usage examples for android.widget LinearLayout.LayoutParams LinearLayout.LayoutParams
public LayoutParams(int width, int height, float weight)
From source file:ca.xef6.firecamp.ProfilePictureSampleFragment.java
private void switchToPresetSize(int sizeType) { customSizeView.setVisibility(View.GONE); presetSizeView.setVisibility(View.VISIBLE); switch (sizeType) { case ProfilePictureView.SMALL: largerButton.setEnabled(true);/*w w w . j a v a 2s. c o m*/ smallerButton.setEnabled(false); sizeLabel.setText("small img"); pictureSizeType = sizeType; break; case ProfilePictureView.NORMAL: largerButton.setEnabled(true); smallerButton.setEnabled(true); sizeLabel.setText("normal img"); pictureSizeType = sizeType; break; case ProfilePictureView.LARGE: default: largerButton.setEnabled(false); smallerButton.setEnabled(true); sizeLabel.setText("large img"); pictureSizeType = ProfilePictureView.LARGE; break; } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1); profilePic.setLayoutParams(params); profilePic.setPresetSize(pictureSizeType); }
From source file:com.facebook.samples.profilepicture.ProfilePictureSampleFragment.java
private void switchToPresetSize(int sizeType) { customSizeView.setVisibility(View.GONE); presetSizeView.setVisibility(View.VISIBLE); switch (sizeType) { case ProfilePictureView.SMALL: largerButton.setEnabled(true);// www . j a va 2s. c om smallerButton.setEnabled(false); sizeLabel.setText(R.string.small_image_size); pictureSizeType = sizeType; break; case ProfilePictureView.NORMAL: largerButton.setEnabled(true); smallerButton.setEnabled(true); sizeLabel.setText(R.string.normal_image_size); pictureSizeType = sizeType; break; case ProfilePictureView.LARGE: default: largerButton.setEnabled(false); smallerButton.setEnabled(true); sizeLabel.setText(R.string.large_image_size); pictureSizeType = ProfilePictureView.LARGE; break; } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1); profilePic.setLayoutParams(params); profilePic.setPresetSize(pictureSizeType); }
From source file:mx.klozz.xperience.tweaker.fragments.CPUSettings.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.cpu_settings, root, false); mIsTegra3 = new File(TEGRA_MAX_FREQ_PATH).exists(); mIsDynFreq = new File(DYN_MAX_FREQ_PATH).exists() && new File(DYN_MIN_FREQ_PATH).exists(); lCurrentCPU = (LinearLayout) view.findViewById(R.id.lCurCPU); mCurFreq = (TextView) view.findViewById(R.id.current_speed); mCurFreq.setOnClickListener(new View.OnClickListener() { @Override// w ww . jav a 2 s .c om public void onClick(View view) { if (nCpus == 1) return; if (++MainActivity.CurrentCPU > (nCpus - 1)) MainActivity.CurrentCPU = 0; setCPUval(MainActivity.CurrentCPU); } }); mCurFreq.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (new File(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU)).exists() && MainActivity.CurrentCPU > 0) { final StringBuilder sb = new StringBuilder(); if (MainActivity.mCPUOn.get(MainActivity.CurrentCPU).equals("1")) { sb.append("set_val \"").append(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU)) .append("\" \"0\";\n"); MainActivity.mCPUOn.set(MainActivity.CurrentCPU, "0"); } else { sb.append("set_val \"").append(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU)) .append("\" \"1\";\n"); MainActivity.mCPUOn.set(MainActivity.CurrentCPU, "1"); } Helpers.shExec(sb, context, true); setCPUval(MainActivity.CurrentCPU); } return true; } }); final int mFrequenciesNum = MainActivity.mAvailableFrequencies.length - 1; mMaxSlider = (SeekBar) view.findViewById(R.id.max_slider); mMaxSlider.setMax(mFrequenciesNum); mMaxSlider.setOnSeekBarChangeListener(this); mMaxSpeedText = (TextView) view.findViewById(R.id.max_speed_text); mMinSlider = (SeekBar) view.findViewById(R.id.min_slider); mMinSlider.setMax(mFrequenciesNum); mMinSlider.setOnSeekBarChangeListener(this); mMinSpeedText = (TextView) view.findViewById(R.id.min_speed_text); mGovernor = (Spinner) view.findViewById(R.id.pref_governor); String[] mAvailableGovernors = Helpers.LeerUnaLinea(GOVERNORS_LIST_PATH).split(" "); ArrayAdapter<CharSequence> governorAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item); governorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String mAvailableGovernor : mAvailableGovernors) { governorAdapter.add(mAvailableGovernor.trim()); } mGovernor.setAdapter(governorAdapter); mGovernor.setSelection(Arrays.asList(mAvailableGovernors) .indexOf(MainActivity.mCurrentGovernor.get(MainActivity.CurrentCPU))); mGovernor.post(new Runnable() { public void run() { mGovernor.setOnItemSelectedListener(new GovListener()); } }); mIo = (Spinner) view.findViewById(R.id.pref_io); String[] mAvailableIo = Helpers.getAvailableIOSchedulers(IO_SCHEDULER_PATH); ArrayAdapter<CharSequence> ioAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item); ioAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (String aMAvailableIo : mAvailableIo) { ioAdapter.add(aMAvailableIo); } mIo.setAdapter(ioAdapter); mIo.setSelection( Arrays.asList(mAvailableIo).indexOf(MainActivity.mCurrentIOSched.get(MainActivity.CurrentCPU))); mIo.post(new Runnable() { public void run() { mIo.setOnItemSelectedListener(new IOListener()); } }); Switch mSetOnBoot = (Switch) view.findViewById(R.id.cpu_sob); mSetOnBoot.setChecked(mPreferences.getBoolean(CPU_SOB, false)); mSetOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton v, boolean checked) { final SharedPreferences.Editor editor = mPreferences.edit(); editor.putBoolean(CPU_SOB, checked); if (checked) { for (int i = 0; i < nCpus; i++) { editor.putString(PREF_MIN_CPU + i, MainActivity.mMinimunFreqSetting.get(i)); editor.putString(PREF_MAX_CPU + i, MainActivity.mMaximunFreqSetting.get(i)); editor.putString(PREF_GOV, MainActivity.mCurrentGovernor.get(i)); editor.putString(PREF_IO, MainActivity.mCurrentIOSched.get(i)); editor.putString("cpuon" + i, MainActivity.mCPUOn.get(i)); } } editor.apply(); } }); //if(nCpus>1){ LinearLayout vcpus[] = new LinearLayout[nCpus]; for (int i = 0; i < nCpus; i++) { vcpus[i] = (LinearLayout) inflater.inflate(R.layout.cpu_view, root, false); vcpus[i].setId(i); TextView nc = (TextView) vcpus[i].findViewById(R.id.ncpu); nc.setText(Integer.toString(i + 1)); if (i != MainActivity.CurrentCPU) nc.setText(" "); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, (float) 0.1); lCurrentCPU.addView(vcpus[i], params); } //} setCPUval(MainActivity.CurrentCPU); return view; }
From source file:cm.aptoide.pt.MainActivity.java
protected void addBreadCrumb(String itemAtPosition, ListDepth depth2) { if (itemAtPosition.contains("http://")) { itemAtPosition = itemAtPosition.split("http://")[1]; itemAtPosition = itemAtPosition.split(".store")[0]; }//from ww w . ja v a 2 s. c om Button bt = (Button) LayoutInflater.from(mContext).inflate(R.layout.breadcrumb, null); bt.setText(itemAtPosition); bt.setTag(new BreadCrumb(depth, breadcrumbs.getChildCount() + 1)); System.out.println(breadcrumbs.getChildCount() + 1); // bt.setOnClickListener(new OnClickListener() { // // @Override // public void onClick(View v) { // depth = ((BreadCrumb) v.getTag()).depth; // breadcrumbs.removeViews(((BreadCrumb) v.getTag()).i , breadcrumbs.getChildCount() - ((BreadCrumb) v.getTag()).i); // refreshAvailableList(true); // } // }); breadcrumbs.addView(bt, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); }