android Programming Glossary: resources
Application Skeleton to support multiple screen http://stackoverflow.com/questions/12242111/application-skeleton-to-support-multiple-screen screen density has most impact on your image and graphic resources It is listed here the percentage difference of device screen.. which is having API11 and it is Hdpi then it will use this resources. Additional Tips Use relative layouts dp sp and mm dp units.. defaults to low density and always loads ldpi specific resources. Resolution pixel dimensions will be correct but your density..
How to disable orientation change in Android? http://stackoverflow.com/questions/1512045/how-to-disable-orientation-change-in-android screenSize From http developer.android.com guide topics resources runtime changes.html#HandlingTheChange Caution Beginning with..
java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android http://stackoverflow.com/questions/1949066/java-lang-outofmemoryerror-bitmap-size-exceeds-vm-budget-android Sometimes the drawables can change. Some are android resources and some are files saved in a folder in the SDCARD. Then the..
How to create Transparent Activity in Android? http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android it. Here ™s a complete file xml version 1.0 encoding utf 8 resources style name Theme.Transparent parent android Theme item name.. item name android backgroundDimEnabled false item style resources the value @color transparent is the color value #00000000 which..
Android: I want to shake it http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it be deactivated onPause and activated onResume to save resources CPU Battery . The code assumes we are on planet Earth and initializes..
Declaring a custom android UI element using XML http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml in values attrs.xml xml version 1.0 encoding utf 8 resources declare styleable name MyCustomView attr name android text attr.. attr name extraInformation format string declare styleable resources Notice the use of an unqualified name in the declare styleable..
Developing for Android in Eclipse: R.java not generating http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating is never updated so it doesn't contain info about my new resources so I decided to delete it and thought that Eclipse will generate..
Custom Drawable for ProgressBar/ProgressDialog http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog a style attrs.xml like this xml version 1.0 encoding utf 8 resources style parent @android style Widget.ProgressBar name customProgressBar.. item name android progressDrawable @anim mp3 item style resources and the in my main.xml I have set the style like this xml version..
Change language programatically in Android http://stackoverflow.com/questions/2900023/change-language-programatically-in-android of an app programmatically while still using Android resources If not is it possible to request a resource in an specific language.. language of the app from the app. android localization resources share improve this question It's possible. You can set the..
notifyDataSetChanged example http://stackoverflow.com/questions/3669325/notifydatasetchanged-example the ArrayAdapter with the new List data. Uses a lot of resources and garbage collection. Create your own class derived from BaseAdapter..
Android: How to declare global variables? http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables data it maintains for the app such as caches of loaded resources pools of objects etc. It works great. I am not arguing that..
Android Activity Life Cycle - What are all these methods for? http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for are no longer in use allowing the OS to reclaim memory and resources. The following diagram illustrates the states an activity can..
R cannot be resolved - Android error http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error named main.xml under res layout . android eclipse android resources share improve this question After tracking down this problem.. android.R statement at the top of your files that use resources especially when you ask Eclipse to sort or otherwise manage..
How did Google manage to do this? Slide ActionBar in Android application http://stackoverflow.com/questions/11234375/how-did-google-manage-to-do-this-slide-actionbar-in-android-application Functions.java public static int dpToPx int dp Context ctx Resources r ctx.getResources return int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP.. static int dpToPx int dp Context ctx Resources r ctx.getResources return int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP..
How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one? http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on import android.content.Context import android.content.res.Resources import android.content.res.TypedArray import android.graphics.Bitmap.. ArrayList Layer mLayers private Matrix mDrawMatrix private Resources mResources public LayeredImageView Context context super context.. mLayers private Matrix mDrawMatrix private Resources mResources public LayeredImageView Context context super context init public..
overlay two images in android to set an imageview http://stackoverflow.com/questions/2739971/overlay-two-images-in-android-to-set-an-imageview void test Bitmap mBitmap BitmapFactory.decodeResource getResources R.drawable.t Bitmap mBitmap2 BitmapFactory.decodeResource getResources.. Bitmap mBitmap2 BitmapFactory.decodeResource getResources R.drawable.tt Bitmap bmOverlay Bitmap.createBitmap mBitmap.getWidth.. image using that Drawable testimage.setImageDrawable getResources .getDrawable R.layout.layer Solution #2 dynamic Resources r..
Change language programatically in Android http://stackoverflow.com/questions/2900023/change-language-programatically-in-android a code if you still need this again i don't recommend that Resources res context.getResources Change locale settings in the app... this again i don't recommend that Resources res context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics..
Android: TabHost without TabActivity http://stackoverflow.com/questions/3163884/android-tabhost-without-tabactivity savedInstanceState setContentView R.layout.mylayout Resources res getResources LocalActivityManager mlam new LocalActivityManager.. setContentView R.layout.mylayout Resources res getResources LocalActivityManager mlam new LocalActivityManager this false..
How to get a resource id with a known ressource name? http://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-ressource-name . If that doesn't work you can always use a context's getResources method ... Drawable resImg this.context.getResources .getDrawable.. getResources method ... Drawable resImg this.context.getResources .getDrawable R.drawable.resource Where this.context is intialised.. Context subclass. Update If it's the name you want the Resources class returned by getResources has a getResourceName int method..
What is Context in Android? http://stackoverflow.com/questions/3572463/what-is-context-in-android getApplicationContext ... Accessing Standard Common Resources Services like LAYOUT_INFLATER_SERVICE SharedPreferences context.getSystemService..
Android VideoView orientation change with buffered video http://stackoverflow.com/questions/4434027/android-videoview-orientation-change-with-buffered-video View.VISIBLE respond.setVisibility View.VISIBLE Resources r getResources int height int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP.. respond.setVisibility View.VISIBLE Resources r getResources int height int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP..
Converting pixels to dp http://stackoverflow.com/questions/4605527/converting-pixels-to-dp this question Converts 14 dip into its equivalent px Resources r getResources float px TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP.. Converts 14 dip into its equivalent px Resources r getResources float px TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP..
Create a NinePatch/NinePatchDrawable in runtime http://stackoverflow.com/questions/5079868/create-a-ninepatch-ninepatchdrawable-in-runtime of the NinePatch. The NinePatch can NOT be loaded from the Resources since the images doesn't exist in res drawable . Furthermore..
Android remove space between tabs in tabwidget http://stackoverflow.com/questions/5799320/android-remove-space-between-tabs-in-tabwidget savedInstanceState setContentView R.layout.main Resources res getResources Resource object to get Drawables TabHost tabHost.. setContentView R.layout.main Resources res getResources Resource object to get Drawables TabHost tabHost TabHost getTabHost..
How do I convert ppi into dpi for Android images? http://stackoverflow.com/questions/6930031/how-do-i-convert-ppi-into-dpi-for-android-images 426dp x 320dp Generalised Dpi values for screens ldpi Resources for low density ldpi screens ~120dpi mdpi Resources for medium.. ldpi Resources for low density ldpi screens ~120dpi mdpi Resources for medium density mdpi screens ~160dpi . This is the baseline.. mdpi screens ~160dpi . This is the baseline density. hdpi Resources for high density hdpi screens ~240dpi . xhdpi Resources for..
Convert list to array in java http://stackoverflow.com/questions/9572795/convert-list-to-array-in-java List Tienda tiendasList tiendas new ArrayList Tienda Resources res this.getBaseContext .getResources XMLParser saxparser new.. new ArrayList Tienda Resources res this.getBaseContext .getResources XMLParser saxparser new XMLParser marca res tiendasList saxparser.parse..
Application Skeleton to support multiple screen http://stackoverflow.com/questions/12242111/application-skeleton-to-support-multiple-screen ppi Typically screen size has most impact on your app layouts screen density has most impact on your image and graphic resources It is listed here the percentage difference of device screen Ldpi 75 Mdpi 100 base according to Android developer site Hdpi.. Android API version i.e. drawable hdpi v11` so the device which is having API11 and it is Hdpi then it will use this resources. Additional Tips Use relative layouts dp sp and mm dp units device independent pixels normalised to 1 physical pixel on.. in inches. If you don't set the device density the emulator defaults to low density and always loads ldpi specific resources. Resolution pixel dimensions will be correct but your density dependent image resources will not display as intended. Of..
How to disable orientation change in Android? http://stackoverflow.com/questions/1512045/how-to-disable-orientation-change-in-android MainActivity android configChanges keyboardHidden orientation screenSize From http developer.android.com guide topics resources runtime changes.html#HandlingTheChange Caution Beginning with Android 3.2 API level 13 the screen size also changes when..
java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android http://stackoverflow.com/questions/1949066/java-lang-outofmemoryerror-bitmap-size-exceeds-vm-budget-android no special effects or anything that can fill the memory. Sometimes the drawables can change. Some are android resources and some are files saved in a folder in the SDCARD. Then the user quits the onDestroy method is executed and app stays in..
How to create Transparent Activity in Android? http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android your res values styles.xml file if you don ™t have one create it. Here ™s a complete file xml version 1.0 encoding utf 8 resources style name Theme.Transparent parent android Theme item name android windowIsTranslucent true item item name android windowBackground.. true item item name android windowIsFloating true item item name android backgroundDimEnabled false item style resources the value @color transparent is the color value #00000000 which I put in res values color.xml file. You can also use @android..
Android: I want to shake it http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it lets say 2 if the device is shaked. Notes The accelometer should be deactivated onPause and activated onResume to save resources CPU Battery . The code assumes we are on planet Earth and initializes the acceleration to earth gravity. Otherwise you would..
Declaring a custom android UI element using XML http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml initialisation. The steps are as follows 1. Declare attributes in values attrs.xml xml version 1.0 encoding utf 8 resources declare styleable name MyCustomView attr name android text attr name android textColor attr name extraInformation format.. attr name android text attr name android textColor attr name extraInformation format string declare styleable resources Notice the use of an unqualified name in the declare styleable tag. Non standard android attributes like extraInformation..
Developing for Android in Eclipse: R.java not generating http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating Eclipse R.java not generating I've found out that my R.java is never updated so it doesn't contain info about my new resources so I decided to delete it and thought that Eclipse will generate a new one. But that didn't happen and I don't have R.java..
Custom Drawable for ProgressBar/ProgressDialog http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog 360 android repeatCount 1 item animation list then created a style attrs.xml like this xml version 1.0 encoding utf 8 resources style parent @android style Widget.ProgressBar name customProgressBar item name android progressDrawable @anim mp3 item.. @android style Widget.ProgressBar name customProgressBar item name android progressDrawable @anim mp3 item style resources and the in my main.xml I have set the style like this xml version 1.0 encoding utf 8 LinearLayout xmlns android http schemas.android.com..
Change language programatically in Android http://stackoverflow.com/questions/2900023/change-language-programatically-in-android programatically in Android Is it possible to change the language of an app programmatically while still using Android resources If not is it possible to request a resource in an specific language I would like to let the user change the language of.. an specific language I would like to let the user change the language of the app from the app. android localization resources share improve this question It's possible. You can set the locale. However i would not recommend that. We've tried it..
notifyDataSetChanged example http://stackoverflow.com/questions/3669325/notifydatasetchanged-example the underlying List add insert remove clear etc. Re create the ArrayAdapter with the new List data. Uses a lot of resources and garbage collection. Create your own class derived from BaseAdapter and ListAdapter that allows changing of the underlying..
Android: How to declare global variables? http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables has tons and tons of singletons for all the little shared data it maintains for the app such as caches of loaded resources pools of objects etc. It works great. I am not arguing that using Singletons cannot work fine or are not a legitimate alternative...
Android Activity Life Cycle - What are all these methods for? http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for This priority system helps Android identify activities that are no longer in use allowing the OS to reclaim memory and resources. The following diagram illustrates the states an activity can go through during its lifetime These states can be broken..
R cannot be resolved - Android error http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error setContentView R.layout.main Why PS I do have an XML file named main.xml under res layout . android eclipse android resources share improve this question After tracking down this problem as well I found this note in the Android documentation http.. using eclipse.html Note Eclipse sometimes likes to add an import android.R statement at the top of your files that use resources especially when you ask Eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these..
How did Google manage to do this? Slide ActionBar in Android application http://stackoverflow.com/questions/11234375/how-did-google-manage-to-do-this-slide-actionbar-in-android-application true menuShown false Some helping methods for me in static Functions.java public static int dpToPx int dp Context ctx Resources r ctx.getResources return int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP dp r.getDisplayMetrics originally http.. Some helping methods for me in static Functions.java public static int dpToPx int dp Context ctx Resources r ctx.getResources return int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP dp r.getDisplayMetrics originally http stackoverflow.com..
How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one? http://stackoverflow.com/questions/16729169/how-to-maintain-multi-layers-of-imageviews-and-keep-their-aspect-ratio-based-on import org.pskink.niohttp.LayeredImageView.Layer import android.content.Context import android.content.res.Resources import android.content.res.TypedArray import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Matrix.. private final static String TAG LayeredImageView private ArrayList Layer mLayers private Matrix mDrawMatrix private Resources mResources public LayeredImageView Context context super context init public LayeredImageView Context context AttributeSet.. final static String TAG LayeredImageView private ArrayList Layer mLayers private Matrix mDrawMatrix private Resources mResources public LayeredImageView Context context super context init public LayeredImageView Context context AttributeSet set super..
overlay two images in android to set an imageview http://stackoverflow.com/questions/2739971/overlay-two-images-in-android-to-set-an-imageview at my canvas.setbitmap line. what am I doing wrong private void test Bitmap mBitmap BitmapFactory.decodeResource getResources R.drawable.t Bitmap mBitmap2 BitmapFactory.decodeResource getResources R.drawable.tt Bitmap bmOverlay Bitmap.createBitmap.. Bitmap mBitmap BitmapFactory.decodeResource getResources R.drawable.t Bitmap mBitmap2 BitmapFactory.decodeResource getResources R.drawable.tt Bitmap bmOverlay Bitmap.createBitmap mBitmap.getWidth mBitmap.getHeight mBitmap.getConfig Canvas canvas new.. t item android drawable @drawable tt layer list Now set the image using that Drawable testimage.setImageDrawable getResources .getDrawable R.layout.layer Solution #2 dynamic Resources r getResources Drawable layers new Drawable 2 layers 0 r.getDrawable..
Change language programatically in Android http://stackoverflow.com/questions/2900023/change-language-programatically-in-android enter activity each activity from my experience. here is a code if you still need this again i don't recommend that Resources res context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration.. from my experience. here is a code if you still need this again i don't recommend that Resources res context.getResources Change locale settings in the app. DisplayMetrics dm res.getDisplayMetrics android.content.res.Configuration conf res.getConfiguration..
Android: TabHost without TabActivity http://stackoverflow.com/questions/3163884/android-tabhost-without-tabactivity public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState setContentView R.layout.mylayout Resources res getResources LocalActivityManager mlam new LocalActivityManager this false TabHost tabHost TabHost findViewById R.id.tabhost.. Bundle savedInstanceState super.onCreate savedInstanceState setContentView R.layout.mylayout Resources res getResources LocalActivityManager mlam new LocalActivityManager this false TabHost tabHost TabHost findViewById R.id.tabhost tabHost.setup..
How to get a resource id with a known ressource name? http://stackoverflow.com/questions/3476430/how-to-get-a-resource-id-with-a-known-ressource-name imported as it can confuse Eclipse if thats what you're using . If that doesn't work you can always use a context's getResources method ... Drawable resImg this.context.getResources .getDrawable R.drawable.resource Where this.context is intialised as.. using . If that doesn't work you can always use a context's getResources method ... Drawable resImg this.context.getResources .getDrawable R.drawable.resource Where this.context is intialised as an Activity Service or any other Context subclass... this.context is intialised as an Activity Service or any other Context subclass. Update If it's the name you want the Resources class returned by getResources has a getResourceName int method and a getResourceTypeName int Update 2 The Resources class..
What is Context in Android? http://stackoverflow.com/questions/3572463/what-is-context-in-android TextView getContext ListAdapter adapter new SimpleCursorAdapter getApplicationContext ... Accessing Standard Common Resources Services like LAYOUT_INFLATER_SERVICE SharedPreferences context.getSystemService LAYOUT_INFLATER_SERVICE getApplicationContext..
Android VideoView orientation change with buffered video http://stackoverflow.com/questions/4434027/android-videoview-orientation-change-with-buffered-video LayoutParams.FILL_PARENT else questionText.setVisibility View.VISIBLE respond.setVisibility View.VISIBLE Resources r getResources int height int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP 150.0f r.getDisplayMetrics questionVideo.setLayoutParams.. else questionText.setVisibility View.VISIBLE respond.setVisibility View.VISIBLE Resources r getResources int height int TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP 150.0f r.getDisplayMetrics questionVideo.setLayoutParams..
Converting pixels to dp http://stackoverflow.com/questions/4605527/converting-pixels-to-dp to convert pixels to dp Any suggestions android share improve this question Converts 14 dip into its equivalent px Resources r getResources float px TypedValue.applyDimension TypedValue.COMPLEX_UNIT_DIP 14 r.getDisplayMetrics share improve this..
Create a NinePatch/NinePatchDrawable in runtime http://stackoverflow.com/questions/5079868/create-a-ninepatch-ninepatchdrawable-in-runtime either need the corresponding NinePatch or the chunk byte of the NinePatch. The NinePatch can NOT be loaded from the Resources since the images doesn't exist in res drawable . Furthermore in order to create the NinePatch you need the chunk of the..
Android remove space between tabs in tabwidget http://stackoverflow.com/questions/5799320/android-remove-space-between-tabs-in-tabwidget public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState setContentView R.layout.main Resources res getResources Resource object to get Drawables TabHost tabHost TabHost getTabHost The activity TabHost TabHost.TabSpec.. onCreate Bundle savedInstanceState super.onCreate savedInstanceState setContentView R.layout.main Resources res getResources Resource object to get Drawables TabHost tabHost TabHost getTabHost The activity TabHost TabHost.TabSpec spec Resusable..
How do I convert ppi into dpi for Android images? http://stackoverflow.com/questions/6930031/how-do-i-convert-ppi-into-dpi-for-android-images screens are at least 470dp x 320dp small screens are at least 426dp x 320dp Generalised Dpi values for screens ldpi Resources for low density ldpi screens ~120dpi mdpi Resources for medium density mdpi screens ~160dpi . This is the baseline density... are at least 426dp x 320dp Generalised Dpi values for screens ldpi Resources for low density ldpi screens ~120dpi mdpi Resources for medium density mdpi screens ~160dpi . This is the baseline density. hdpi Resources for high density hdpi screens ~240dpi.. ldpi screens ~120dpi mdpi Resources for medium density mdpi screens ~160dpi . This is the baseline density. hdpi Resources for high density hdpi screens ~240dpi . xhdpi Resources for extra high density xhdpi screens ~320dpi . Therefore generalised..
Convert list to array in java http://stackoverflow.com/questions/9572795/convert-list-to-array-in-java to an array in java Check the code below ArrayList Tienda tiendas List Tienda tiendasList tiendas new ArrayList Tienda Resources res this.getBaseContext .getResources XMLParser saxparser new XMLParser marca res tiendasList saxparser.parse marca res.. ArrayList Tienda tiendas List Tienda tiendasList tiendas new ArrayList Tienda Resources res this.getBaseContext .getResources XMLParser saxparser new XMLParser marca res tiendasList saxparser.parse marca res tiendas tiendasList.toArray this.adaptador..
|