List of usage examples for android.widget LinearLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:org.namelessrom.devicecontrol.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // setup action bar final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . j a v a 2 s . c o m toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mSubFragmentTitle == -1) { sSlidingMenu.toggle(true); } else { onCustomBackPressed(true); } } }); // setup material menu icon sMaterialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, MaterialMenuDrawable.Stroke.THIN) { @Override public int getToolbarViewId() { return R.id.toolbar; } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { sMaterialMenu.setNeverDrawTouch(true); } Utils.setupDirectories(); final FrameLayout container = (FrameLayout) findViewById(R.id.container); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { container.setBackground(null); } else { //noinspection deprecation container.setBackgroundDrawable(null); } final View v = getLayoutInflater().inflate(R.layout.menu_list, container, false); final ListView menuList = (ListView) v.findViewById(R.id.navbarlist); final LinearLayout menuContainer = (LinearLayout) v.findViewById(R.id.menu_container); // setup our static items menuContainer.findViewById(R.id.menu_prefs).setOnClickListener(this); menuContainer.findViewById(R.id.menu_about).setOnClickListener(this); sSlidingMenu = new SlidingMenu(this); sSlidingMenu.setMode(SlidingMenu.LEFT); sSlidingMenu.setShadowWidthRes(R.dimen.shadow_width); sSlidingMenu.setShadowDrawable(R.drawable.shadow_left); sSlidingMenu.setBehindWidthRes(R.dimen.slidingmenu_offset); sSlidingMenu.setFadeEnabled(true); sSlidingMenu.setFadeDegree(0.45f); sSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); sSlidingMenu.setMenu(v); // setup touch mode MainActivity.setSwipeOnContent(DeviceConfiguration.get(this).swipeOnContent); // setup menu list setupMenuLists(); final MenuListArrayAdapter mAdapter = new MenuListArrayAdapter(this, R.layout.menu_main_list_item, mMenuEntries, mMenuIcons); menuList.setAdapter(mAdapter); menuList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); menuList.setOnItemClickListener(this); loadFragmentPrivate(DeviceConstants.ID_ABOUT, false); getSupportFragmentManager().executePendingTransactions(); Utils.startTaskerService(); final String downgradePath = getFilesDir() + DeviceConstants.DC_DOWNGRADE; if (Utils.fileExists(downgradePath)) { if (!new File(downgradePath).delete()) { Logger.wtf(this, "Could not delete downgrade indicator file!"); } Toast.makeText(this, R.string.downgraded, Toast.LENGTH_LONG).show(); } if (DeviceConfiguration.get(this).dcFirstStart) { DeviceConfiguration.get(this).dcFirstStart = false; DeviceConfiguration.get(this).saveConfiguration(this); } }
From source file:com.brewcrewfoo.performance.fragments.TimeInState.java
private View generateStateRow(CpuState state, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); LinearLayout view = (LinearLayout) inflater.inflate(R.layout.state_row, parent, false); float per = (float) state.duration * 100 / monitor.getTotalStateTime(); String sPer = (int) per + "%"; String sFreq;//from w w w .j av a2 s. c o m if (state.freq == 0) { sFreq = getString(R.string.deep_sleep); } else { sFreq = state.freq / 1000 + " MHz"; } long tSec = state.duration / 100; String sDur = toString(tSec); TextView freqText = (TextView) view.findViewById(R.id.ui_freq_text); TextView durText = (TextView) view.findViewById(R.id.ui_duration_text); TextView perText = (TextView) view.findViewById(R.id.ui_percentage_text); ProgressBar bar = (ProgressBar) view.findViewById(R.id.ui_bar); freqText.setText(sFreq); perText.setText(sPer); durText.setText(sDur); bar.setProgress((int) per); parent.addView(view); return view; }
From source file:com.money.manager.ex.home.DashboardFragment.java
private View showTableLayoutUpComingTransactions(Cursor cursor) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null); CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext()); Core core = new Core(getActivity().getApplicationContext()); // Textview Title TextView title = (TextView) layout.findViewById(R.id.textViewTitle); title.setText(R.string.upcoming_transactions); // Table/*from www . ja va 2 s . c om*/ TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary); // add rows while (cursor.moveToNext()) { // load values String payee = "<i>" + cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)) + "</i>"; double total = cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT)); int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT)); int currencyId = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID)); String daysLeftText = ""; daysLeftText = Integer.toString(Math.abs(daysLeft)) + " " + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue); TableRow row = createTableRow( new String[] { "<small>" + payee + "</small>", "<small>" + currencyService.getCurrencyFormatted(currencyId, MoneyFactory.fromDouble(total)) + "</small>", "<small>" + daysLeftText + "</small>" }, new Float[] { 1f, null, 1f }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }); TextView txt = (TextView) row.getChildAt(2); UIHelper uiHelper = new UIHelper(getActivity()); int color = daysLeft >= 0 ? uiHelper.resolveAttribute(R.attr.holo_green_color_theme) : uiHelper.resolveAttribute(R.attr.holo_red_color_theme); txt.setTextColor(ContextCompat.getColor(getActivity(), color)); // Add Row tableLayout.addView(row); } // return Layout return layout; }
From source file:uk.org.downiesoft.slideshow.BrowserAdapter.java
/** * {@inheritDoc}//w w w .j a v a 2s . c om */ @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout browserItemView; Holder holder; if (convertView == null) { browserItemView = new LinearLayout(mContext); mInflater.inflate(mResource, browserItemView, true); holder = new Holder(); holder.image = (ImageView) browserItemView.findViewById(R.id.rowImage); holder.name = (TextView) browserItemView.findViewById(R.id.rowFilename); holder.count = (TextView) browserItemView.findViewById(R.id.rowCount); browserItemView.setTag(holder); } else { browserItemView = (LinearLayout) convertView; holder = (Holder) browserItemView.getTag(); } final ImageView imageView = holder.image; final TextView textView = holder.name; final TextView countView = holder.count; ZFile item = getItem(position); String name = item.getName(); if (item.isDirectory() && item.getSubPath().length() == 0) { if (mThumbBitmaps.get(position) != null) imageView.setImageBitmap(mThumbBitmaps.get(position)); else imageView.setImageResource(R.drawable.folder); textView.setText(name.substring(0, name.length())); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText("\u2026"); } } else if (item.getSubPath().equals(mContext.getString(R.string.text_images_placeholder))) { imageView.setImageBitmap(mThumbBitmaps.get(position)); textView.setText(name.substring(0, name.length())); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText(""); } } else { if (mThumbBitmaps.get(position) != null) imageView.setImageBitmap(mThumbBitmaps.get(position)); else imageView.setImageResource(R.drawable.ic_launcher); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText("\u2026"); } textView.setText(name); } return browserItemView; }
From source file:com.sentaroh.android.BluetoothWidget.Log.LogFileListDialogFragment.java
private void setContextButtonNormalMode(LogFileListAdapter lfm_adapter) { final TextView dlg_title = (TextView) mDialog.findViewById(R.id.log_file_list_dlg_title); dlg_title.setText(mDialogTitle);/*from w w w . j a v a 2s .c om*/ final ImageButton dlg_done = (ImageButton) mDialog.findViewById(R.id.log_file_list_dlg_done); dlg_done.setVisibility(ImageButton.GONE); LinearLayout ll_prof = (LinearLayout) mDialog.findViewById(R.id.log_context_view); LinearLayout ll_delete = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_delete_view); LinearLayout ll_share = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_share_view); LinearLayout ll_rotate_log = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_rotate_log_view); LinearLayout ll_select_all = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_select_all_view); LinearLayout ll_unselect_all = (LinearLayout) ll_prof .findViewById(R.id.log_context_button_unselect_all_view); ll_delete.setVisibility(LinearLayout.GONE); ll_share.setVisibility(LinearLayout.GONE); ll_rotate_log.setVisibility(LinearLayout.VISIBLE); if (lfm_adapter.isEmptyAdapter()) { ll_select_all.setVisibility(LinearLayout.GONE); ll_unselect_all.setVisibility(LinearLayout.GONE); } else { ll_select_all.setVisibility(LinearLayout.VISIBLE); ll_unselect_all.setVisibility(LinearLayout.GONE); } }
From source file:im.vector.activity.SettingsActivity.java
private boolean areChanges() { if (mTmpThumbnailUriBySession.size() != 0) { return true; }//from w w w . j av a 2s. c om for (MXSession session : Matrix.getMXSessions(this)) { LinearLayout linearLayout = mLinearLayoutBySession.get(session); EditText displayNameEditText = (EditText) linearLayout.findViewById(R.id.editText_displayName); if (UIUtils.hasFieldChanged(session.getMyUser().displayname, displayNameEditText.getText().toString())) { return true; } } return false; }
From source file:net.ddns.mlsoftlaberge.contactslist.ui.ContactsBudgetFragment.java
private void filltransactionlayout() { // Each LinearLayout has the same LayoutParams so this can // be created once and used for each cumulative layouts of data tlayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); // Clears out the details layout first in case the details // layout has data from a previous data load still // added as children. budget_layout.removeAllViews();/*from www.ja va 2 s . c om*/ gtot = 0.0f; // loop thru all the clients for (int i = 0; i < nbclients; ++i) { if (clientslist[i].nbtransac != 0) { fillclientlayout(i); } } // add a row with the gtot amount LinearLayout tlayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contacts_budget_trans, null, false); TextView descrip = (TextView) tlayout.findViewById(R.id.budget_trans_descrip); TextView amount = (TextView) tlayout.findViewById(R.id.budget_trans_amount); descrip.setText("TOTAL"); descrip.setTextSize(18.0f); amount.setText(String.format("%.2f", gtot)); amount.setTextSize(18.0f); budget_layout.addView(tlayout, tlayoutParams); }
From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java
private void setChooseTabViewTextColor(int position) { int childCount = tabsContainer.getChildCount(); LinearLayout tabView; TextView textView;//from ww w . j a v a 2s.c o m for (int i = 0; i < childCount; ++i) { tabView = (LinearLayout) tabsContainer.getChildAt(i); textView = (TextView) tabView.findViewById(R.id.tab_title_label); if (i == position) { textView.setTextColor(getResources().getColor(checkedTextColor)); } else { textView.setTextColor(getResources().getColor(unCheckedTextColor)); } } }
From source file:net.ddns.mlsoftlaberge.contactslist.ui.ContactsBudgetFragment.java
public void fillclientlayout(int clientno) { LinearLayout clayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contacts_budget_item, null, false); TextView id = (TextView) clayout.findViewById(R.id.budget_id); TextView name = (TextView) clayout.findViewById(R.id.budget_name); TextView phone = (TextView) clayout.findViewById(R.id.budget_phone); TextView email = (TextView) clayout.findViewById(R.id.budget_email); TextView address = (TextView) clayout.findViewById(R.id.budget_address); LinearLayout blayout = (LinearLayout) clayout.findViewById(R.id.budget_trans); id.setText(clientslist[clientno].id); name.setText(clientslist[clientno].name); phone.setText(clientslist[clientno].phone); email.setText(clientslist[clientno].email); address.setText(clientslist[clientno].address); blayout.removeAllViews();//from w ww. j a v a 2 s . com // loop thru all transactions of the client for (int i = 0; i < clientslist[clientno].nbtransac; ++i) { // Builds the transaction layout // Inflates the transaction layout LinearLayout tlayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contacts_budget_trans, null, false); TextView descrip = (TextView) tlayout.findViewById(R.id.budget_trans_descrip); TextView amount = (TextView) tlayout.findViewById(R.id.budget_trans_amount); // get the current transaction Transac transac = clientslist[clientno].transaclist.elementAt(i); // fill the fields with the table data descrip.setText(transac.descrip); amount.setText(transac.amount); // cumulate the total amount gtot += Double.valueOf(transac.amount); // Adds the new note layout to the notes layout blayout.addView(tlayout, tlayoutParams); } // add the client layout in the budget layout budget_layout.addView(clayout, tlayoutParams); }
From source file:org.ambient.control.config.EditConfigFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // integrate object into existing configuration after child fragment has data left for us via onIntegrate. We do the // integration here after the arguments and bundles have been restored. We cannot merge the values in onCreate() because // it will only be called from android when the fragment instance has been removed before. e.g. screen rotation. if (this.valueToIntegrate != null) { this.integrateConfiguration(this.valueToIntegrate); }/*ww w . j a va 2 s . c o m*/ try { ScrollView result = (ScrollView) inflater.inflate(R.layout.fragment_edit_config, container, false); LinearLayout content = (LinearLayout) result.findViewById(R.id.linearLayoutEditConfigContent); // init the maps for grouped and sorted fields Map<Integer, Map<Integer, Field>> sortedMap = new TreeMap<Integer, Map<Integer, Field>>(); // and a simple list for those fields which have no sort description List<Field> unsortedList = new ArrayList<Field>(); // create groups if class description is present and defines some ClassDescription description = beanToEdit.getClass().getAnnotation(ClassDescription.class); if (description != null) { for (Group currentGroup : description.groups()) { Map<Integer, Field> category = new TreeMap<Integer, Field>(); sortedMap.put(currentGroup.position(), category); } } else { // create a default group sortedMap.put(0, new TreeMap<Integer, Field>()); } // sort fields that are annotated in groups for (final Field field : beanToEdit.getClass().getFields()) { // only use field with typedef annotation. the rest of the // fields will be ignored if (field.isAnnotationPresent(TypeDef.class)) { if (field.isAnnotationPresent(Presentation.class)) { // put into groups Presentation presentation = field.getAnnotation(Presentation.class); sortedMap.get(presentation.groupPosition()).put(presentation.position(), field); } else { // or to unsorted group if no information for sorting is // present unsortedList.add(field); } } } // if no sorted values haven been drawn we create a default group on // screen and put all unsorted values in there. if some have been // drawn we put them into a "misc" group. we could do a check at the // beginning if several groups have been filled and so on. but we // render them first and get the information as result of that. boolean sortedValuesDrawn = false; for (Integer currentCategoryId : sortedMap.keySet()) { if (sortedMap.get(currentCategoryId).isEmpty()) { continue; } LinearLayout categoryView = (LinearLayout) inflater.inflate(R.layout.layout_editconfig_group_header, null); TextView title = (TextView) categoryView.findViewById(R.id.textViewGroupHeader); TextView descriptionTextView = (TextView) categoryView.findViewById(R.id.textViewGroupDescription); content.addView(categoryView); if (currentCategoryId == 0) { // draw allgemein for category 0. if an group with id 0 is // described the values will be overwritten in next step title.setText("ALLGEMEIN"); descriptionTextView.setVisibility(View.GONE); } // draw the category header and a description if present if (description != null) { for (Group currentGroup : description.groups()) { if (currentGroup.position() == currentCategoryId) { title.setText(currentGroup.name()); if (currentGroup.description().isEmpty() == false) { descriptionTextView.setText(currentGroup.description()); descriptionTextView.setVisibility(View.VISIBLE); } else { descriptionTextView.setVisibility(View.GONE); } break; } } } // draw all handlers for the fields in this category Map<Integer, Field> values = sortedMap.get(currentCategoryId); for (Field field : values.values()) { addFieldToView(inflater, beanToEdit, content, field); // we are shure that the default or a special category have // been used. if there are unsorted values put them into an // additional group later sortedValuesDrawn = true; } } // draw a header for unsorted fields if class description provided // categories for the other fields if (sortedValuesDrawn && unsortedList.isEmpty() == false) { LinearLayout categoryFurther = (LinearLayout) inflater .inflate(R.layout.layout_editconfig_group_header, null); TextView title = (TextView) categoryFurther.findViewById(R.id.textViewGroupHeader); title.setText("WEITERE"); TextView descriptionTextView = (TextView) categoryFurther .findViewById(R.id.textViewGroupDescription); descriptionTextView.setVisibility(View.GONE); content.addView(categoryFurther); } // draw the handlers for (Field currentField : unsortedList) { addFieldToView(inflater, beanToEdit, content, currentField); } // default text if no fields are annotated if (sortedValuesDrawn == false && unsortedList.isEmpty()) { TextView tv = new TextView(content.getContext()); tv.setText("Dieses Objekt wird nicht konfiguriert"); content.addView(tv); } return result; } catch (Exception e) { Log.e(LOG, "could not create View for bean: " + beanToEdit.getClass().getName(), e); return null; } }