List of usage examples for android.widget RelativeLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.sbhstimetable.sbhs_timetable_android.CountdownFragment.java
public void updateTimer() { final View f = this.getView(); if (f == null) { return;/* www.ja v a2 s . co m*/ } if (timeLeft != null) { cancelling = true; timeLeft.cancel(); cancelling = false; } RelativeLayout extraData = (RelativeLayout) f.findViewById(R.id.countdown_extraData); TextView teacher = (TextView) extraData.findViewById(R.id.countdown_extraData_teacher); teacher.setText(""); TextView room = (TextView) extraData.findViewById(R.id.countdown_extraData_room); room.setText(""); TextView subject = (TextView) extraData.findViewById(R.id.countdown_extraData_subject); subject.setText(""); String label = "Something"; String connector = "happens in"; TodayJson.Period p = null; if (DateTimeHelper.bells != null) { BelltimesJson.Bell next = DateTimeHelper.bells.getNextBell(); if (next != null) { BelltimesJson.Bell now = DateTimeHelper.bells.getIndex(next.getIndex() - 1); if (now.isPeriod() && now.getPeriodNumber() < 5) { // in a period, it's not last period. connector = "ends in"; if (ApiAccessor.isLoggedIn() && TodayJson.getInstance() != null) { p = TodayJson.getInstance().getPeriod(now.getPeriodNumber()); label = p.name(); teacher.setText(p.teacher()); room.setText(p.room()); subject.setText(p.name()); extraData.setVisibility(View.VISIBLE); } else { label = now.getLabel(); extraData.setVisibility(View.INVISIBLE); } } else if (now.isPeriod() && now.getPeriodNumber() == 5) { // last period connector = "in"; label = "School ends"; extraData.setVisibility(View.INVISIBLE); } else if (now.getIndex() + 1 < DateTimeHelper.bells.getMaxIndex() && DateTimeHelper.bells.getIndex(now.getIndex() + 1).isPeriod()) { // in a break followed by a period - Lunch 2, Recess, Transition. connector = "starts in"; if (ApiAccessor.isLoggedIn() && TodayJson.getInstance() != null) { p = TodayJson.getInstance() .getPeriod(DateTimeHelper.bells.getIndex(now.getIndex() + 1).getPeriodNumber()); label = p.name(); teacher.setText(p.teacher()); room.setText(p.room()); subject.setText(p.name()); extraData.setVisibility(View.VISIBLE); } else { label = DateTimeHelper.bells.getIndex(now.getIndex() + 1).getLabel(); extraData.setVisibility(View.VISIBLE); } } else { // There's consecutive non-periods - i.e lunch 1 -> lunch 2 label = now.getLabel(); connector = "starts in"; } } else { // end of day label = "School starts"; connector = "in"; if (TodayJson.getInstance() != null && TodayJson.getInstance().getPeriod(1) != null) { extraData.setVisibility(View.VISIBLE); p = TodayJson.getInstance().getPeriod(1); teacher.setText(p.teacher()); room.setText(p.room()); subject.setText(p.name()); } else { extraData.setVisibility(View.INVISIBLE); } } } if (p != null) { if (p.teacherChanged()) { teacher.setTextColor(getActivity().getResources().getColor(R.color.standout)); } else { //teacher.setTextColor(getActivity().getResources().getColor(R.color.secondary_text_dark)); } if (p.roomChanged()) { room.setTextColor(getActivity().getResources().getColor(R.color.standout)); } else { //room.setTextColor(getActivity().getResources().getColor(android.R.color.secondary_text_dark)); } } final String innerLabel = label; ((TextView) f.findViewById(R.id.countdown_name)).setText(label); ((TextView) f.findViewById(R.id.countdown_in)).setText(connector); final TextView t = (TextView) f.findViewById(R.id.countdown_countdown); final CountdownFragment frag = this; CountDownTimer timer = new CountDownTimer(DateTimeHelper.milliSecondsUntilNextEvent(), 1000) { long lastTime = 10000; boolean isLast = innerLabel.equals("School ends"); @Override public void onTick(long l) { lastTime = l; t.setText(DateTimeHelper.formatToCountdown(l)); } @Override public void onFinish() { if (this.lastTime <= 1000 && !cancelling) { if (this.isLast) { ApiAccessor.getToday(frag.getActivity()); ApiAccessor.getBelltimes(frag.getActivity()); } final Handler h = new Handler(); h.postDelayed(new Runnable() { @Override public void run() { updateTimer(); } }, 1000); } } }; timer.start(); timeLeft = timer; }
From source file:com.microsoft.band.sdksample.TilesFragment.java
@SuppressLint("InflateParams") @Override//from w ww .j av a2 s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_tiles, container, false); mListTiles = (ListView) rootView.findViewById(R.id.listTiles); RelativeLayout header = (RelativeLayout) inflater.inflate(R.layout.fragment_tiles_header, null); mTextRemainingCapacity = (TextView) header.findViewById(R.id.textAvailableCapacity); mButtonAddTile = (Button) header.findViewById(R.id.buttonAddTile); mButtonAddTile.setOnClickListener(mButtonAddTileClickListener); mButtonRemoveTile = (Button) header.findViewById(R.id.buttonRemoveTile); mButtonRemoveTile.setOnClickListener(mButtonRemoveTileClickListener); mCheckboxBadging = (CheckBox) header.findViewById(R.id.cbBadging); mThemeView = (BandThemeView) header.findViewById(R.id.viewCustomTheme); mThemeView.setTheme(BandTheme.CYBER_THEME); mCheckboxCustomTheme = (CheckBox) header.findViewById(R.id.cbCustomTheme); mCheckboxCustomTheme.setOnCheckedChangeListener(this); mEditTileName = (EditText) header.findViewById(R.id.editTileName); mEditTileName.addTextChangedListener(this); RelativeLayout footer = (RelativeLayout) inflater.inflate(R.layout.fragment_tiles_footer, null); mEditTitle = (EditText) footer.findViewById(R.id.editTitle); mEditBody = (EditText) footer.findViewById(R.id.editBody); mCheckboxWithDialog = (CheckBox) footer.findViewById(R.id.cbWithDialog); mButtonSendMessage = (Button) footer.findViewById(R.id.buttonSendMessage); mButtonSendMessage.setOnClickListener(mButtonSendMessageClickListener); mButtonSendDialog = (Button) footer.findViewById(R.id.buttonSendDialog); mButtonSendDialog.setOnClickListener(mButtonShowDialogClickListener); mListTiles.addHeaderView(header); mListTiles.addFooterView(footer); mTileListAdapter = new TileListAdapter(); mListTiles.setAdapter(mTileListAdapter); mListTiles.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { position -= 1; // ignore the header if (position >= 0 && position < mTileListAdapter.getCount()) { mSelectedTile = (BandTile) mTileListAdapter.getItem(position); refreshControls(); } } }); return rootView; }
From source file:it_minds.dk.eindberetningmobil_android.views.StartActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.startactivity_menu, menu); final MenuItem badgeItem = menu.findItem(R.id.missing_trip_menu_counter); final RelativeLayout badgeLayout = (RelativeLayout) badgeItem.getActionView(); //Set badge//from ww w . ja v a 2 s .c o m if (badgeCount > 0) { badgeItem.setVisible(true); TextView tv = (TextView) badgeLayout.findViewById(R.id.actionbar_notifcation_textview); tv.setText(badgeCount + ""); } else { badgeItem.setVisible(false); } return true; }
From source file:com.fastbootmobile.encore.app.fragments.RecognitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.fragment_recognition, container, false); // Recognition layout mButtonLayout = (LinearLayout) root.findViewById(R.id.llRecognitionButton); mRecognitionButton = (AnimatedMicButton) root.findViewById(R.id.btnStartRec); mTvStatus = (TextView) root.findViewById(R.id.tvStatus); mTvDetails = (TextView) root.findViewById(R.id.tvDetailsText); // Result layout mCardResult = (CardView) root.findViewById(R.id.cardResult); mTvAlbum = (TextView) root.findViewById(R.id.tvAlbumName); mTvArtist = (TextView) root.findViewById(R.id.tvArtistName); mTvTitle = (TextView) root.findViewById(R.id.tvTrackName); mIvArt = (ImageView) root.findViewById(R.id.ivRecognitionArt); mSearchButton = (Button) root.findViewById(R.id.btnSearch); mTvOfflineError = (TextView) root.findViewById(R.id.tvErrorMessage); mTvOfflineError.setText(R.string.error_recognition_unavailable_offline); ProviderAggregator aggregator = ProviderAggregator.getDefault(); mTvOfflineError.setVisibility(aggregator.isOfflineMode() ? View.VISIBLE : View.GONE); mRecognitionButton.setOnClickListener(new View.OnClickListener() { @Override//from ww w . ja v a 2s. c o m public void onClick(View view) { if (mActivePrint == null) { mActivePrint = new EchoPrint(RecognitionFragment.this); mActivePrint.startRecording(); onRecognitionStartUI(); // The buffer has a max size of 20 seconds, so we force stop at around 19 seconds mHandler.postDelayed(mStopRecognition, 19000); } else { mHandler.removeCallbacks(mStopRecognition); mStopRecognition.run(); } } }); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent search = new Intent(getActivity(), SearchActivity.class); search.setAction(Intent.ACTION_SEARCH); search.putExtra(SearchManager.QUERY, mLastResult.ArtistName + " " + mLastResult.TrackName); startActivity(search); } }); return root; }
From source file:com.nadmm.airports.aeronav.DtppFragment.java
protected void showOtherCharts(LinearLayout layout) { RelativeLayout item = (RelativeLayout) inflate(R.layout.grouped_detail_item); TextView tv = (TextView) item.findViewById(R.id.group_name); LinearLayout group = (LinearLayout) item.findViewById(R.id.group_details); tv.setText("Other"); addChartRow(group, "", "Airport Diagram Legend", "legendAD.pdf", "", ""); addChartRow(group, "", "Legends & General Information", "frntmatter.pdf", "", ""); layout.addView(item, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
From source file:com.nadmm.airports.aeronav.DtppFragment.java
protected void showChartGroup(LinearLayout layout, Cursor c) { if (c.moveToFirst()) { String chartCode = c.getString(c.getColumnIndex(DatabaseManager.Dtpp.CHART_CODE)); RelativeLayout item = (RelativeLayout) inflate(R.layout.grouped_detail_item); TextView tv = (TextView) item.findViewById(R.id.group_name); tv.setText(DataUtils.decodeChartCode(chartCode)); LinearLayout group = (LinearLayout) item.findViewById(R.id.group_details); do {/* w w w . j a v a2 s . c o m*/ String chartName = c.getString(c.getColumnIndex(DatabaseManager.Dtpp.CHART_NAME)); String pdfName = c.getString(c.getColumnIndex(DatabaseManager.Dtpp.PDF_NAME)); String userAction = c.getString(c.getColumnIndex(DatabaseManager.Dtpp.USER_ACTION)); String faanfd18 = c.getString(c.getColumnIndex(DatabaseManager.Dtpp.FAANFD18_CODE)); addChartRow(group, chartCode, chartName, pdfName, userAction, faanfd18); } while (c.moveToNext()); layout.addView(item, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } }
From source file:org.disrupted.rumble.userinterface.activity.HomeActivity.java
public View renderTabView(Context context, int iconResource) { RelativeLayout view = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.badge_tab_layout, null);/*from www . j a v a 2 s . c o m*/ view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ((ImageView) view.findViewById(R.id.tab_icon)).setImageResource(iconResource); ((TextView) view.findViewById(R.id.tab_badge)).setVisibility(View.INVISIBLE); return view; }
From source file:com.nadmm.airports.aeronav.DtppFragment.java
protected void showDtppSummary(Cursor[] result) { LinearLayout topLayout = (LinearLayout) findViewById(R.id.dtpp_detail_layout); Cursor cycle = result[1];//from w w w . j a v a 2 s . c o m cycle.moveToFirst(); mTppCycle = cycle.getString(cycle.getColumnIndex(DatabaseManager.DtppCycle.TPP_CYCLE)); String from = cycle.getString(cycle.getColumnIndex(DatabaseManager.DtppCycle.FROM_DATE)); String to = cycle.getString(cycle.getColumnIndex(DatabaseManager.DtppCycle.TO_DATE)); RelativeLayout item = (RelativeLayout) inflate(R.layout.grouped_detail_item); TextView tv = (TextView) item.findViewById(R.id.group_name); tv.setVisibility(View.GONE); LinearLayout layout = (LinearLayout) item.findViewById(R.id.group_details); addRow(layout, "Cycle", mTppCycle); // Parse chart cycle effective dates SimpleDateFormat df = new SimpleDateFormat("HHmm'Z' MM/dd/yy", Locale.US); df.setTimeZone(java.util.TimeZone.getTimeZone("UTC")); Date toDate = null; try { toDate = df.parse(to); } catch (ParseException ignored) { } if (toDate != null) { addRow(layout, "Valid", TimeUtils.formatDateTime(getActivity(), toDate.getTime())); Cursor dtpp = result[2]; dtpp.moveToFirst(); String tppVolume = dtpp.getString(0); addRow(layout, "Volume", tppVolume); // Determine if chart cycle has expired Date now = new Date(); if (now.getTime() > toDate.getTime()) { mExpired = true; addRow(layout, "WARNING: This chart cycle has expired."); } } topLayout.addView(item, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
From source file:com.nextgis.forestinspector.fragment.MapFragment.java
protected void showMapButtons(boolean show, RelativeLayout rl) { if (null == rl) { return;/*from www .j a va 2s .com*/ } View v = rl.findViewById(R.id.action_zoom_out); if (null != v) { if (show) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.GONE); } } v = rl.findViewById(R.id.action_zoom_in); if (null != v) { if (show) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.GONE); } } rl.invalidate(); }
From source file:com.oceansky.yellow.app.fragments.RecognitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.fragment_recognition, container, false); // Recognition layout mButtonLayout = (LinearLayout) root.findViewById(R.id.llRecognitionButton); mRecognitionButton = (AnimatedMicButton) root.findViewById(R.id.btnStartRec); mTvStatus = (TextView) root.findViewById(R.id.tvStatus); mTvDetails = (TextView) root.findViewById(R.id.tvDetailsText); // Result layout mCardResult = (CardView) root.findViewById(R.id.cardResult); mTvAlbum = (TextView) root.findViewById(R.id.tvAlbumName); mTvArtist = (TextView) root.findViewById(R.id.tvArtistName); mTvTitle = (TextView) root.findViewById(R.id.tvTrackName); mIvArt = (ImageView) root.findViewById(R.id.ivRecognitionArt); mSearchButton = (Button) root.findViewById(R.id.btnSearch); mTvOfflineError = (TextView) root.findViewById(R.id.tvErrorMessage); mTvOfflineError.setText(R.string.error_recognition_unavailable_offline); ProviderAggregator aggregator = ProviderAggregator.getDefault(); mTvOfflineError.setVisibility(aggregator.isOfflineMode() ? View.VISIBLE : View.GONE); mRecognitionButton.setOnClickListener(new View.OnClickListener() { @Override//w w w. j a v a 2 s .c o m public void onClick(View view) { if (mActivePrint == null) { // Ensure we have the permissions to record audio if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.RECORD_AUDIO }, MY_PERMISSIONS_REQUEST_RECORD_AUDIO); } else { startRecording(); } } else { mHandler.removeCallbacks(mStopRecognition); mStopRecognition.run(); } } }); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent search = new Intent(getActivity(), SearchActivity.class); search.setAction(Intent.ACTION_SEARCH); search.putExtra(SearchManager.QUERY, mLastResult.ArtistName + " " + mLastResult.TrackName); startActivity(search); } }); return root; }