List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java
@Override protected void onServiceBound() { L.d("ServiceActionMenuActivity onServiceBound()"); final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf"); final int defaultFirstRowTextColor = Color.parseColor("#646464"); final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class); final ServiceMenu menu = friendsPlugin.getStore().getMenu(email, page); TableLayout menu_table = (TableLayout) findViewById(R.id.menu_table); int tableWidth = menu_table.getWidth(); for (int x = 0; x < 4; x++) { for (int y = 0; y < 3; y++) { android.view.ViewGroup cellLayout = (android.view.ViewGroup) findViewById( getResources().getIdentifier("menu_" + x + "x" + y, "id", getPackageName())); android.view.ViewGroup.LayoutParams lp = cellLayout.getLayoutParams(); lp.width = tableWidth / 4;//www . j a va 2s . c o m cellLayout.setLayoutParams(lp); Cell cell = new Cell(); cell.icon = (ImageView) cellLayout.findViewById(R.id.icon); cell.faIcon = (TextView) cellLayout.findViewById(R.id.fa_icon); cell.label = (TextView) cellLayout.findViewById(R.id.label); cells[x][y] = cell; if (y == 0) { cell.icon.setVisibility(View.GONE); cell.faIcon.setTypeface(faTypeFace); cell.faIcon.setTextColor(defaultFirstRowTextColor); switch (x) { case 0: cell.faIcon.setVisibility(View.VISIBLE); cell.faIcon.setText(R.string.fa_info); break; case 1: cell.faIcon.setVisibility(View.VISIBLE); cell.faIcon.setText(R.string.fa_envelope); break; case 2: cell.faIcon.setVisibility(View.INVISIBLE); cell.faIcon.setText(R.string.fa_phone); break; case 3: cell.faIcon.setVisibility(View.INVISIBLE); cell.faIcon .setText(CloudConstants.isYSAAA() ? R.string.fa_qrcode : R.string.fa_thumbs_o_up); break; default: break; } } } } for (int y = 0; y < 3; y++) { TableRow row = (TableRow) findViewById(getResources().getIdentifier("row" + y, "id", getPackageName())); tableRows[y] = row; } clearScreen(); populateScreen(menu); IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_UPDATE_INTENT); filter.addAction(FriendsPlugin.FRIEND_REMOVED_INTENT); filter.addAction(FriendsPlugin.FRIEND_MARKED_FOR_REMOVAL_INTENT); filter.addAction(MessagingPlugin.NEW_MESSAGE_RECEIVED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_PROCESSED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_LOCKED_INTENT); filter.addAction(MessagingPlugin.MESSAGE_DIRTY_CLEANED_INTENT); filter.addAction(MessagingPlugin.THREAD_DELETED_INTENT); filter.addAction(MessagingPlugin.THREAD_RECOVERED_INTENT); filter.addAction(BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT); filter.addAction(BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT); filter.addAction(MessagingPlugin.MESSAGE_JSMFR_ERROR); registerReceiver(mBroadcastReceiver, filter); findViewById(R.id.navigation_bar_home_button).setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { Intent i = new Intent(ServiceActionMenuActivity.this, HomeActivity.class); i.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(i); finish(); } }); }
From source file:org.andstatus.app.msg.TimelineActivity.java
private void prepareDrawer() { ViewGroup mDrawerList = (ViewGroup) findViewById(R.id.navigation_drawer); if (mDrawerList == null) { return;/*from w w w.j av a 2s .co m*/ } TextView item = (TextView) mDrawerList.findViewById(R.id.timelineTypeButton); item.setText(timelineTypeButtonText()); prepareCombinedTimelineToggle(mDrawerList); updateAccountButtonText(mDrawerList); }
From source file:com.mooshim.mooshimeter.main.ScanActivity.java
private void refreshMeterTile(final MooshimeterDevice d, final ViewGroup wrapper) { if (wrapper.getChildCount() == 0) { Log.e(TAG, "Received empty wrapper"); }//from w ww . ja v a 2s. c o m if (wrapper.getChildCount() > 0) { // Update the title bar int rssi = d.mRssi; String name; String build; if (d.mOADMode) { name = "Bootloader"; } else { name = d.getBLEDevice().getName(); if (name == null) { name = "Unknown device"; } } if (d.mBuildTime == 0) { build = "Invalid firmware"; } else { build = "Build: " + d.mBuildTime; } String descr = name + "\n" + build + "\nRssi: " + rssi + " dBm"; ((TextView) wrapper.findViewById(R.id.descr)).setText(descr); final Button bv = (Button) wrapper.findViewById(R.id.btnConnect); int bgid = d.mConnectionState == BluetoothProfile.STATE_CONNECTED ? R.drawable.connected : R.drawable.disconnected; bv.setBackground(getResources().getDrawable(bgid)); // Set the click listeners bv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleConnectionState(bv, d); } }); } if (d.mInitialized && !d.isInOADMode()) { // We are representing a connected meter if (wrapper.getChildCount() != 2) { // We need to create a new value pane wrapper.addView(mInflater.inflate(R.layout.element_mm_readingsbar, mDeviceScrollView, false)); } Util.dispatch(new Runnable() { @Override public void run() { if (!d.isNotificationEnabled(d.getChar(MooshimeterDevice.mUUID.METER_SAMPLE))) { // We need to enable notifications d.playSampleStream(new Runnable() { @Override public void run() { TextView ch1 = (TextView) wrapper.findViewById(R.id.ch1_value_label); TextView ch2 = (TextView) wrapper.findViewById(R.id.ch2_value_label); TextView ch1_unit = (TextView) wrapper.findViewById(R.id.ch1_unit_label); TextView ch2_unit = (TextView) wrapper.findViewById(R.id.ch2_unit_label); valueLabelRefresh(0, d, ch1, ch1_unit); valueLabelRefresh(1, d, ch2, ch2_unit); } }); } } }); } else { //We are representing a disconnected meter or a meter in OAD mode if (wrapper.getChildCount() == 2) { // We need to eliminate a pane wrapper.removeViewAt(1); } } }
From source file:de.dreier.mytargets.views.MaterialTapTargetPrompt.java
/** * Returns {@link #mParentView}./*w w w. j a v a 2 s . c o m*/ * <p> * If the {@link #mParentView} is {@link null} it determines what view it should be. * * @return The view to add the prompt view to. */ private ViewGroup getParentView() { if (mParentView == null) { final ViewGroup decorView = (ViewGroup) mActivity.getWindow().getDecorView(); final ViewGroup contentView = (ViewGroup) ((ViewGroup) decorView.findViewById(android.R.id.content)) .getChildAt(0); // If the content view is a drawer layout then that is the parent so // that the prompt can be added behind the navigation drawer if (contentView.getClass().getName().equals("android.support.v4.widget.DrawerLayout")) { mParentView = contentView; mParentViewIsDecor = false; } else { mParentView = decorView; mParentViewIsDecor = true; } mView.mClipBounds = mParentViewIsDecor; } return mParentView; }
From source file:net.openwatch.acluaz.fragment.FormFragment.java
/** * Populate form given the db_id of an Incident in the database * This currently assumes that the database columns are equal to the view_tags (json keys) * @param container//from w w w . j a va 2s.c om * @param db_id */ protected void fillFormFromDatabase(ViewGroup container, int db_id) { String TAG = "FormFragment-fillFormFromDatabase"; Incident incident = Incident.objects(this.getActivity().getApplicationContext()).get(db_id); if (incident == null) return; ContentValues values = new ContentValues(); try { incident.collectData(getActivity().getApplicationContext(), values, Incident.class); } catch (IllegalArgumentException e) { Log.e(TAG, "Unable to collect ContentValues from Incident"); e.printStackTrace(); } catch (IllegalAccessException e) { Log.e(TAG, "Unable to collect ContentValues from Incident"); e.printStackTrace(); } View form_input; for (Entry<String, ?> entry : values.valueSet()) { if (entry.getKey().compareTo(getString(R.string.device_lat)) == 0 || entry.getKey().compareTo(getString(R.string.device_lon)) == 0) { // Combine lat and lon into a Location and tag the gps toggle form_input = container.findViewById(R.id.gps_toggle); Location loc = new Location("db"); loc.setLatitude(values.getAsDouble(DBConstants.DEVICE_LAT)); loc.setLongitude(values.getAsDouble(DBConstants.DEVICE_LON)); form_input.setTag(R.id.view_tag, loc); } else if (entry.getKey().compareTo(getString(R.string.date_tag)) == 0) { form_input = container.findViewById(R.id.date_input); if (form_input == null || entry.getValue() == null) continue; String date = (String) entry.getValue(); try { ((EditText) form_input) .setText(Constants.date_formatter.format(Constants.datetime_formatter.parse(date))); form_input = container.findViewById(R.id.time_input); if (form_input == null) continue; ((EditText) form_input) .setText(Constants.time_formatter.format(Constants.datetime_formatter.parse(date))); } catch (ParseException e) { Log.e(TAG, "Error setting date time form fields from database datetime"); e.printStackTrace(); } } else { // If the column value is simply bound to the view // with tag equal to column name... form_input = container.findViewWithTag(entry.getKey()); setFormFieldValue(form_input, entry); } } }
From source file:android.support.transition.TransitionPort.java
/** * Recursive method that captures values for the given view and the * hierarchy underneath it.//from ww w . j a va 2 s.c om * * @param sceneRoot The root of the view hierarchy being captured * @param start true if this capture is happening before the scene change, * false otherwise */ void captureValues(ViewGroup sceneRoot, boolean start) { clearValues(start); if (mTargetIds.size() > 0 || mTargets.size() > 0) { if (mTargetIds.size() > 0) { for (int i = 0; i < mTargetIds.size(); ++i) { int id = mTargetIds.get(i); View view = sceneRoot.findViewById(id); if (view != null) { TransitionValues values = new TransitionValues(); values.view = view; if (start) { captureStartValues(values); } else { captureEndValues(values); } if (start) { mStartValues.viewValues.put(view, values); if (id >= 0) { mStartValues.idValues.put(id, values); } } else { mEndValues.viewValues.put(view, values); if (id >= 0) { mEndValues.idValues.put(id, values); } } } } } if (mTargets.size() > 0) { for (int i = 0; i < mTargets.size(); ++i) { View view = mTargets.get(i); if (view != null) { TransitionValues values = new TransitionValues(); values.view = view; if (start) { captureStartValues(values); } else { captureEndValues(values); } if (start) { mStartValues.viewValues.put(view, values); } else { mEndValues.viewValues.put(view, values); } } } } } else { captureHierarchy(sceneRoot, start); } }
From source file:com.geecko.QuickLyric.MainActivity.java
private void setupDemoScreen() { ViewGroup rootView = (ViewGroup) findViewById(id.root_view); getLayoutInflater().inflate(layout.tutorial_view, rootView); final ViewPager pager = (ViewPager) findViewById(id.pager); CirclePageIndicator indicator = (CirclePageIndicator) findViewById(id.indicator); final IntroScreenSlidePagerAdapter pagerAdapter = new IntroScreenSlidePagerAdapter(getFragmentManager(), this); pager.setAdapter(pagerAdapter);/* w w w . j a v a2s . c o m*/ pager.addOnPageChangeListener(pagerAdapter); indicator.setViewPager(pager); pager.setCurrentItem(pagerAdapter.rightToLeft ? pagerAdapter.getCount() - 1 : 0); indicator.setOnPageChangeListener(pagerAdapter); Button skipButton = (Button) rootView.findViewById(id.pager_button); ImageButton arrowButton = (ImageButton) rootView.findViewById(id.pager_arrow); skipButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) pagerAdapter.exitAction(); else pager.setCurrentItem(pagerAdapter.getCount() - 1); } }); arrowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pagerAdapter.nextAction(); } }); if (mDrawerToggle != null) ((DrawerLayout) drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); focusOnFragment = false; invalidateOptionsMenu(); }
From source file:mp.teardrop.LibraryActivity.java
/** * Used to lock the Dropbox file browser UI while retrieving directory contents from Dropbox. *//* www . ja va2 s. c o m*/ private void lockDropboxFileBrowser() { ViewGroup dbLayout = mPagerAdapter.mContainingLayouts[MediaUtils.TYPE_DROPBOX]; View screen = dbLayout.findViewById(R.id.list_view_loading_screen); screen.setVisibility(View.VISIBLE); }
From source file:mp.teardrop.LibraryActivity.java
/** * Used to unlock the Dropbox file browser after we're done retrieving directory contents. *//*from w w w .jav a2 s.c o m*/ private void unlockDropboxFileBrowser() { ViewGroup dbLayout = mPagerAdapter.mContainingLayouts[MediaUtils.TYPE_DROPBOX]; View screen = dbLayout.findViewById(R.id.list_view_loading_screen); screen.setVisibility(View.GONE); }
From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java
private void styleInfoSnackbar() { ViewGroup group = (ViewGroup) snackbar.getView(); group.setBackgroundColor(getResources().getColor(R.color.primary)); snackbar.setActionTextColor(getResources().getColor(R.color.accent)); TextView tv = (TextView) group.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(getResources().getColor(R.color.text_on_primary)); }