List of usage examples for android.widget RelativeLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:eu.funceptionapps.convertitall.ui.UnitFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { prefs = PreferenceManager.getDefaultSharedPreferences(ConverterInterface.thisContext); RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.unit_fragment, container, false); ImageButton switchButton = (ImageButton) layout.findViewById(R.id.bt_switch); switchButton.setImageResource(R.drawable.ic_switch_button_holo_light); EditText edUnitIn = (EditText) layout.findViewById(R.id.ed_unitIn); EditText edUnitOut = (EditText) layout.findViewById(R.id.ed_unitOut); SpinnerList = new ArrayList<String>(); for (int i = 0; i < selectedUnits.length; i++) { if (selectedUnits[i]) { SpinnerList.add(units[i]);//from w ww .ja v a 2 s . c o m } } fromSpinner = (Spinner) layout.findViewById(R.id.sp_from_unit); toSpinner = (Spinner) layout.findViewById(R.id.sp_to_unit); if (converter == Converter.CURRENCY) { unitFromAdapter = new CurrencyAdapter(ConverterInterface.thisContext, R.layout.spinner_row, SpinnerList); } else { unitFromAdapter = new ArrayAdapter<String>(ConverterInterface.thisContext, android.R.layout.simple_spinner_item, SpinnerList); } unitFromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); unitToAdapter = unitFromAdapter; unitToAdapter.notifyDataSetChanged(); fromSpinner.setAdapter(unitFromAdapter); if (SpinnerList.size() > recentFromItemId) fromSpinner.setSelection(recentFromItemId); toSpinner.setAdapter(unitToAdapter); if (SpinnerList.size() > recentToItemId) toSpinner.setSelection(recentToItemId); OnLongClickListener wikiLongClickListenerFrom = new OnLongClickListener() { public boolean onLongClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(units_wiki[fromSpinner.getSelectedItemPosition()])); startActivity(i); return false; } }; OnLongClickListener wikiLongClickListenerTo = new OnLongClickListener() { public boolean onLongClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(units_wiki[toSpinner.getSelectedItemPosition()])); startActivity(i); return false; } }; fromSpinner.setOnLongClickListener(wikiLongClickListenerFrom); toSpinner.setOnLongClickListener(wikiLongClickListenerTo); switchButton.setOnClickListener( new OnSwitchClickListener(fromSpinner, toSpinner, edUnitIn, edUnitOut, converter)); edUnitIn.addTextChangedListener( new OnTextChangedListener(fromSpinner, toSpinner, edUnitIn, edUnitOut, converter)); fromSpinner.setOnItemSelectedListener( new OnSpinnerItemChangedListener(fromSpinner, toSpinner, edUnitIn, edUnitOut, converter)); toSpinner.setOnItemSelectedListener( new OnSpinnerItemChangedListener(fromSpinner, toSpinner, edUnitIn, edUnitOut, converter)); return layout; }
From source file:com.nadmm.airports.wx.AirSigmetFragment.java
protected void showAirSigmetEntry(LinearLayout layout, AirSigmetEntry entry) { RelativeLayout item = (RelativeLayout) inflate(R.layout.airsigmet_detail_item); TextView tv = (TextView) item.findViewById(R.id.airsigmet_type); tv.setText(entry.type);//from ww w . j a va 2s . c om tv = (TextView) item.findViewById(R.id.wx_raw_airsigmet); tv.setText(entry.rawText); tv = (TextView) item.findViewById(R.id.airsigmet_time); tv.setText(TimeUtils.formatDateRange(getActivity(), entry.fromTime, entry.toTime)); LinearLayout details = (LinearLayout) item.findViewById(R.id.airsigmet_details); if (entry.hazardType != null && entry.hazardType.length() > 0) { addRow(details, "Type", entry.hazardType); } if (entry.hazardSeverity != null && entry.hazardSeverity.length() > 0) { addRow(details, "Severity", entry.hazardSeverity); } if (entry.minAltitudeFeet < Integer.MAX_VALUE || entry.maxAltitudeFeet < Integer.MAX_VALUE) { addRow(details, "Altitude", FormatUtils.formatFeetRangeMsl(entry.minAltitudeFeet, entry.maxAltitudeFeet)); } if (entry.movementDirDegrees < Integer.MAX_VALUE) { StringBuilder sb = new StringBuilder(); sb.append(String.format("%s (%s)", FormatUtils.formatDegrees(entry.movementDirDegrees), GeoUtils.getCardinalDirection(entry.movementDirDegrees))); if (entry.movementSpeedKnots < Integer.MAX_VALUE) { sb.append(String.format(" at %d knots", entry.movementSpeedKnots)); } addRow(details, "Movement", sb.toString()); } layout.addView(item, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:com.github.omadahealth.circularbarpager.library.CircularBarPager.java
/** * Init the view by getting the {@link CircularBar}, * the {@link android.support.v4.view.ViewPager} and the {@link com.viewpagerindicator.CirclePageIndicator}. * Init also some default values as PageTranformer etc... *//*from w w w . jav a 2 s .c o m*/ private void initializeView(AttributeSet attrs, int defStyleAttr) { if (attrs != null) { final TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.CircularViewPager, defStyleAttr, 0); boolean enableOnClick = attributes .getBoolean(R.styleable.CircularViewPager_progress_pager_on_click_enabled, false); isPaddingSet = false; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.circularbar_view_pager, this); mCircularBar = (CircularBar) view.findViewById(R.id.circular_bar); mViewPager = (ViewPager) view.findViewById(R.id.view_pager); mCirclePageIndicator = (CirclePageIndicator) view.findViewById(R.id.circle_page_indicator); //Default init if (mCircularBar != null) { mCircularBar.loadStyledAttributes(attrs, defStyleAttr); } if (mViewPager != null) { mViewPager.setPageTransformer(false, new FadeViewPagerTransformer()); } //If we enable onClick, ie. we can switch between pages with both a swipe and a touch //Touch just goes to the next page % number of pages if (enableOnClick) { final GestureDetectorCompat tapGestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapConfirmed(MotionEvent e) { mViewPager.setCurrentItem( (mViewPager.getCurrentItem() + 1) % mViewPager.getAdapter().getCount()); return super.onSingleTapConfirmed(e); } }); if (mViewPager != null) { mViewPager.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { tapGestureDetector.onTouchEvent(event); return false; } }); } } } }
From source file:org.zirco.ui.components.CustomPagerAdapter.java
public int addPage(int position) { RelativeLayout view = (RelativeLayout) mInflater.inflate(R.layout.webview, mViewPager, false); CustomWebView webView = (CustomWebView) view.findViewById(R.id.webview); webView = initializeWebView(webView); Tab tab = new Tab(view, webView); if (position == -1) { mTabs.add(tab);/* w w w. ja v a2 s . c om*/ } else { mTabs.add(position, tab); } int index = mTabs.indexOf(tab); notifyDataSetChanged(); return index; }
From source file:com.keifermiller.inkbar.activities.IBActivity.java
@Override public void setContentView(int layoutResId) { RelativeLayout iBContent = (RelativeLayout) View.inflate(this, R.layout.ib_activity_layout, null); ViewStub stub = (ViewStub) iBContent.findViewById(R.id.view_stub); stub.setLayoutResource(layoutResId); stub.inflate();/*from www.ja v a 2s .c om*/ super.setContentView(iBContent, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)); }
From source file:com.lithidsw.wallbox.app.wallsnap.WallpaperFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RelativeLayout rl = (RelativeLayout) inflater.inflate(R.layout.wallpaper_frag, container, false); if (rl != null) { fa = super.getActivity(); wallGrid = (GridView) rl.findViewById(R.id.grid_view); prefs = fa.getSharedPreferences(C.PREF, Context.MODE_PRIVATE); if (!prefs.getBoolean(C.PREF_WALLPAPER_CHECK_SAVE_SORT, false)) { prefs.edit().putInt(C.PREF_WALLPAPER_CURRENT_SORT, 0).commit(); }/*from w w w . j a va 2 s . com*/ wallGrid = (GridView) rl.findViewById(R.id.grid_view); mTextView = (TextView) rl.findViewById(R.id.no_content); wallAdapter = new WallpaperAdapter(fa, aWall); wallGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(fa, WallSnapActivity.class); Bundle bundle = new Bundle(); bundle.putString(C.EXTRA_PATH, aWall.get(position)[0]); intent.putExtras(bundle); startActivity(intent); } }); wallGrid.setAdapter(wallAdapter); setHasOptionsMenu(true); if (!prefs.getBoolean(C.PREF_WALLPAPER_FIRST_RUN_MAIN, false)) { prefs.edit().putBoolean(C.PREF_WALLPAPER_FIRST_RUN_MAIN, true).commit(); String title = getResources().getString(R.string.main_title_wallpapers); String message = getResources().getString(R.string.wallpaper_description); new CustomDialogs().openFirstDialog(fa, title, message); } } return rl; }
From source file:fr.ippon.android.opendata.android.AbstractParkingListFragment.java
private void configureSearchField(RelativeLayout r) { final AbstractParkingListFragment loaderCallBack = this; searchField = (EditText) r.findViewById(R.id.searchField); if (TextUtils.isEmpty(searchField.getText())) searchField.setText(searchHint); searchField.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // hide the keyboard InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(searchField.getWindowToken(), 0); // Perform action on key press boolean okSearch = !TextUtils.isEmpty(searchField.getText()) && !searchHint.equals(searchField.getText()); queryText = okSearch ? searchField.getText().toString() : null; Log.d(TAG, "query: " + queryText); hasSearched = true;//from w w w. j a v a 2 s .co m getLoaderManager().restartLoader(0, null, loaderCallBack); if (queryText == null) { searchField.setText(searchHint); } return true; } return false; } }); // afichage d'une croix dans l'edit text pour effacer le texte saisie final Drawable x = getResources().getDrawable(R.drawable.ic_cancel); x.setBounds(0, 0, x.getIntrinsicWidth(), x.getIntrinsicHeight()); searchField.setCompoundDrawables(null, null, x, null); searchField.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && searchHint.equals(searchField.getText().toString())) { searchField.setText(""); } if (searchField.getCompoundDrawables()[2] == null) { // cross is not being shown so no need to handle return false; } if (event.getAction() != MotionEvent.ACTION_DOWN) { // only respond to the down type return false; } if (event.getX() > searchField.getMeasuredWidth() - searchField.getPaddingRight() - x.getIntrinsicWidth()) { searchField.setText(""); return true; } else { return false; } } }); }
From source file:com.msopentech.applicationgateway.AgentsActivity.java
@Override public void onExecutionComplete(int operation, Object[] result) { try {/* w w w .jav a 2 s. com*/ mIsWorkInProgress = false; if (result == null) { AgentsActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Utility.showToastNotification(getResources().getString(R.string.agents_obtain_failed)); return; } }); } else { JSONArray rawAgentsStorage = (JSONArray) result[0]; ConnectionTraits traits = (ConnectionTraits) result[1]; for (int i = 0; i < rawAgentsStorage.length(); i++) { try { JSONObject item = rawAgentsStorage.getJSONObject(i); String agent_name = item.getString(Router.JSON_AGENT_DISPLAY_NAME_KEY); String agent_id = item.getString(Router.JSON_AGENT_ID_KEY); if (traits.agent.getAgentId().contentEquals(agent_id)) { agent_name = IN_USE_MARK + agent_name; } mAgentsDataStorage.add(new AgentEntity(agent_id, agent_name)); } catch (JSONException e) { continue; } } int agentsNumber = mAgentsDataStorage.size(); if (agentsNumber == 0) { Utility.showToastNotification("There are no agents available."); return; } String agentNames[] = new String[agentsNumber]; for (int i = 0; i < agentsNumber; i++) { agentNames[i] = mAgentsDataStorage.elementAt(i).getDisplayName(); } RelativeLayout agentsHeader = (RelativeLayout) getLayoutInflater().inflate(R.layout.list_header, null); ((TextView) agentsHeader.findViewById(R.id.list_header)).setText(R.string.agents_list_header); mAgentsListView.addHeaderView(agentsHeader, agentNames, false); ArrayAdapter<String> list1 = new ArrayAdapter<String>(AgentsActivity.this, android.R.layout.simple_list_item_1, agentNames); mAgentsListView.setAdapter(list1); showWorkInProgress(false); } showWorkInProgress(mIsWorkInProgress); } catch (final Exception e) { Utility.showAlertDialog( AgentsActivity.class.getSimpleName() + ".onPostExecute(): Failed. " + e.toString(), AgentsActivity.this); } }
From source file:ac.robinson.mediaphone.provider.NarrativeAdapter.java
public View newView(Context context, Cursor cursor, ViewGroup parent) { final RelativeLayout view = (RelativeLayout) mInflater.inflate(R.layout.frame_browser, parent, false); NarrativeViewHolder holder = new NarrativeViewHolder(); // TODO: soft references to the list view? delete on destroy? holder.frameList = (HorizontalListView) view.findViewById(R.id.narrative_list_view); view.setTag(holder);//from ww w .j av a2s . c o m holder.frameList.setOnItemClickListener(mActivity.getFrameClickListener()); holder.frameList.setOnItemLongClickListener(mActivity.getFrameLongClickListener()); return view; }
From source file:net.kjmaster.cookiemom.booth.add.AddBoothDialogFragment.java
private void showDateTimeDialog() { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) getActivity().getLayoutInflater() .inflate(R.layout.ui_date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); // Check is system is set to use 24h time (this doesn't seem to work as expected though) final String timeS = android.provider.Settings.System.getString(getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked mDateTimeDialogView.findViewById(R.id.SetDateTime).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); // TODO Auto-generated method stub String eventDate = SimpleDateFormat.getDateInstance(DateFormat.LONG) .format(new Date(mDateTimePicker.getDateTimeMillis())); ((TextView) getActivity().findViewById(R.id.Date)).setText(eventDate); if (mDateTimePicker.is24HourView()) { ((TextView) getActivity().findViewById(R.id.Time)).setText( mDateTimePicker.get(Calendar.HOUR_OF_DAY) + ":" + mDateTimePicker.get(Calendar.MINUTE)); } else { NumberFormat fmt = NumberFormat.getNumberInstance(); fmt.setMinimumIntegerDigits(2); ((TextView) getActivity().findViewById(R.id.Time)) .setText(fmt.format(mDateTimePicker.get(Calendar.HOUR)) + ":" + fmt.format(mDateTimePicker.get(Calendar.MINUTE)) + " " + (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM")); }//w w w . ja v a 2 s. c om hiddenDateTime.setText(String.valueOf(mDateTimePicker.getDateTimeMillis())); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked mDateTimeDialogView.findViewById(R.id.CancelDialog).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is clicked mDateTimeDialogView.findViewById(R.id.ResetDateTime).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); }