List of usage examples for android.view View setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.scigames.slidegame.ObjectiveActivity.java
@Override protected void onNewIntent(Intent i) { View thisView = findViewById(R.id.objective_page); //find view setContentView(thisView);//from www .ja va2s . co m thisView.setBackgroundResource(R.drawable.bg_blank); objectiveImgNum = 0; objectiveImg = null; if (i.getExtras().getString("slideLevel") != null) { Log.d(TAG, "onNewIntent!"); rfidIn = i.getStringExtra("rfid"); studentIdIn = i.getStringExtra("studentId"); slideLevelIn = i.getStringExtra("slideLevel"); String thisSlideLevel = i.getExtras().getString("slideLevel"); getObjectiveImages(slideLevelIn); } }
From source file:com.klinker.android.theme_spotlight.activity.SpotlightActivity.java
private void hackSearchView() { // hack to change the search actionbar icon from that crappy low res default int searchImgId = getResources().getIdentifier("android:id/search_button", null, null); ImageView view = (ImageView) mSearchView.findViewById(searchImgId); view.setImageResource(R.drawable.ic_action_search); // hack to change the magnifying glass low res image searchImgId = getResources().getIdentifier("android:id/search_mag_icon", null, null); view = (ImageView) mSearchView.findViewById(searchImgId); view.setImageResource(R.drawable.ic_action_search); // hack to change the close button low res image searchImgId = getResources().getIdentifier("android:id/search_close_btn", null, null); view = (ImageView) mSearchView.findViewById(searchImgId); view.setImageResource(R.drawable.ic_action_cancel); // hack to change the search edit text background to white int searchEditTextId = getResources().getIdentifier("android:id/search_plate", null, null); View autoCompleteView = mSearchView.findViewById(searchEditTextId); autoCompleteView.setBackgroundResource(R.drawable.searchview_textfield_activated_holo_light); }
From source file:com.breadwallet.BreadWalletApp.java
/** * Shows a custom toast using the given string as a paramater, * * @param message the message to be shown in the custom toast *//*w ww . j a va 2s.co m*/ public void showCustomToast(Activity app, String message, int yOffSet, int duration, int color) { if (toast == null) toast = new Toast(getApplicationContext()); if (MainActivity.appInBackground) return; if (customToastAvailable || !oldMessage.equals(message)) { oldMessage = message; customToastAvailable = false; new Handler().postDelayed(new Runnable() { @Override public void run() { customToastAvailable = true; } }, 1000); LayoutInflater inflater = app.getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) app.findViewById(R.id.toast_layout_root)); if (color == 1) { layout.setBackgroundResource(R.drawable.toast_layout_black); } TextView text = (TextView) layout.findViewById(R.id.toast_text); text.setText(message); toast.setGravity(Gravity.BOTTOM, 0, yOffSet); toast.setDuration(duration); toast.setView(layout); toast.show(); } }
From source file:com.github.johnpersano.supertoasts.demo.views.TabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); int tabTypefaceStyle = Typeface.BOLD; tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(i == currentPosition ? tabTextColor : tabDeactivateTextColor); }// ww w . j a v a 2s. c o m } }
From source file:net.etuldan.sparss.adapter.FiltersCursorAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { TextView isAcceptRuleTextView = (TextView) view.findViewById(android.R.id.text1); TextView filterTextTextView = (TextView) view.findViewById(android.R.id.text2); TextView isAppliedToTitleTextView = (TextView) view.findViewById(R.id.text3); if (cursor.getPosition() == mSelectedFilter) { view.setBackgroundResource( PrefUtils.getBoolean(PrefUtils.LIGHT_THEME, true) ? R.color.light_accent_color : R.color.dark_accent_color); } else {/* w w w.jav a2 s .c o m*/ view.setBackgroundResource(android.R.color.transparent); } boolean isAcceptRule = cursor.getInt(mIsAcceptRulePosition) == 1; isAcceptRuleTextView.setText(isAcceptRule ? R.string.accept : R.string.reject); isAcceptRuleTextView.setTextColor(isAcceptRule ? ContextCompat.getColor(context, R.color.green) : ContextCompat.getColor(context, R.color.red)); filterTextTextView.setText(cursor.getString(mFilterTextColumnPosition)); isAppliedToTitleTextView .setText(cursor.getInt(mIsAppliedToTitleColumnPosition) == 1 ? R.string.filter_apply_to_title : R.string.filter_apply_to_content); }
From source file:fr.univsavoie.ltp.client.map.Popup.java
/** * Afficher sur la map un popup qui propose a l'utilisateur * de mettre a jours son status//from w ww .j av a 2 s . c o m */ public final void popupPublishStatus() { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; int popupWidth = (int) (width * 0.75); //int popupHeight = height / 2; // Inflate the popup_layout.xml ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_set_status, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupPublishStatus.setBackgroundDrawable(new BitmapDrawable()); popupPublishStatus.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); } }); /* * Evenements composants du PopupWindow */ // Ecouteur d'vnement sur le bouton pour se dconnecter Button publish = (Button) layout.findViewById(R.id.btStatusPublish); publish.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus); if (userStatus.getText().toString().length() == 0) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else if (userStatus.getText().toString().length() < 3) { Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); } else { String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \"" + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \"" + String.valueOf(activity.getLatitude()) + "\",\"content\" : \"" + userStatus.getText().toString() + "\"}}}"; activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", json); Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show(); popupPublishStatus.dismiss(); // Actualise les marqueurs activity.displayFriends(); } } }); }
From source file:bigshots.people_helping_people.scroll_iew_lib.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(16);/*w w w. jav a 2s . c om*/ tab.setTypeface(tabTypeface, tabTypefaceStyle); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper.java
/** * @param viewId//from www.j a va2 s . com * @param backgroundResId ?id * @return */ public BGAViewHolderHelper setBackgroundRes(@IdRes int viewId, int backgroundResId) { View view = getView(viewId); view.setBackgroundResource(backgroundResId); return this; }
From source file:fr.univsavoie.ltp.client.map.Popup.java
/** * Afficher une boite au milieu de la carte si aucun utilisateur est connects * pour proposer a l'invit, de se connecter ou s'incrire aupres du service LTP. *///from www.ja v a 2 s .c o m public final void popupGuest() { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; //final int height = dm.heightPixels; int popupWidth = (int) (width * 0.75); //int popupHeight = height / 2; // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupGuest); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_guest, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupGuest = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupGuest.setBackgroundDrawable(new BitmapDrawable()); popupGuest.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupGuest.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); } }); /* * Evenements composants du PopupWindow */ // Ecouteur d'vnement sur le bouton des paramtres Button btLogin = (Button) layout.findViewById(R.id.btnPopupLogin); btLogin.setOnClickListener(new OnClickListener() { public void onClick(View view) { // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte // (requestCode) qui sera utilis plus tard pour identifier lactivit // renvoyant la valeur de retour. Intent i = new Intent(activity, LoginActivity.class); activity.startActivityForResult(i, 1); popupGuest.dismiss(); } }); // Ecouteur d'vnement sur le bouton des paramtres Button btSignup = (Button) layout.findViewById(R.id.btnPopupSignup); btSignup.setOnClickListener(new OnClickListener() { public void onClick(View view) { // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte // (requestCode) qui sera utilis plus tard pour identifier lactivit // renvoyant la valeur de retour. Intent i = new Intent(activity, SignupActivity.class); activity.startActivityForResult(i, 3); popupGuest.dismiss(); } }); // Ecouteur d'vnement sur le bouton pour fermer l'application Button close = (Button) layout.findViewById(R.id.btnPopupClose); close.setOnClickListener(new OnClickListener() { public void onClick(View v) { popupGuest.dismiss(); } }); }
From source file:fr.univsavoie.ltp.client.map.Popup.java
public final void popupGetStatus(JSONArray pStatusesArray) { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; final int height = dm.heightPixels; int popupWidth = (int) (width * 0.75); int popupHeight = height; // Inflate the popup_layout.xml ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupGetStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_get_status, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupPublishStatus.setBackgroundDrawable(new BitmapDrawable()); popupPublishStatus.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); }/*www.ja v a2s .c om*/ }); /* * Evenements composants du PopupWindow */ // Find the ListView resource. ListView mainListView = (ListView) layout.findViewById(R.id.listViewStatus); ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); SimpleAdapter adapter = new SimpleAdapter(this.activity, list, R.layout.custom_row_view, new String[] { "content", "lat", "lon" }, new int[] { R.id.text1, R.id.text2, R.id.text3 }); try { // Appel REST pour recuperer les status de l'utilisateur connect //Session session = new Session(this.activity); //session.parseJSONUrl("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", "GET"); // Parser la liste des amis dans le OverlayItem ArrayList HashMap<String, String> temp; for (int i = 0; (i < 6); i++) { // Obtenir le status JSONObject status = pStatusesArray.getJSONObject(i); temp = new HashMap<String, String>(); temp.put("content", status.getString("content")); temp.put("lat", String.valueOf(status.getDouble("lat"))); temp.put("lon", String.valueOf(status.getDouble("lon"))); list.add(temp); } } catch (JSONException jex) { Log.e("Catch", "popupGetStatus / JSONException : " + jex.getStackTrace()); } catch (Exception ex) { Log.e("Catch", "popupGetStatus / Exception : " + ex.getLocalizedMessage()); } mainListView.setAdapter(adapter); }