Lint: How to ignore ” is not translated in ” errors?

Android Studio: “File” > “Settings” and type “MissingTranslation” into the search box Eclipse: Windows/Linux: In “Window” > “Preferences” > “Android” > “Lint Error Checking” Mac: “Eclipse” > “Preferences” > “Android” > “Lint Error Checking” Find the MissingTranslation line, and set it to Warning as seen below:

How to get a resource id with a known resource name?

If I understood right, this is what you want int drawableResourceId = this.getResources().getIdentifier(“nameOfDrawable”, “drawable”, this.getPackageName()); Where “this” is an Activity, written just to clarify. In case you want a String in strings.xml or an identifier of a UI element, substitute “drawable” int resourceId = this.getResources().getIdentifier(“nameOfResource”, “id”, this.getPackageName()); I warn you, this way of obtaining identifiers … Read more

String Resource new line /n not possible?

use a blackslash not a forwardslash. \n <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”title”>Hello\nWorld!</string> </resources> Also, if you plan on using the string as HTML, you can use &lt;br /&gt; for a line break(<br />) <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”title”>Hello&lt;br /&gt;World!</string> </resources>

How can I assign an ID to a view programmatically?

Android id overview An Android id is an integer commonly used to identify views; this id can be assigned via XML (when possible) and via code (programmatically.) The id is most useful for getting references for XML-defined Views generated by an Inflater (such as by using setContentView.) Assign id via XML Add an attribute of … Read more

How to clear an ImageView in Android?

I used to do it with the dennis.sheppard solution: viewToUse.setImageResource(0); it works but it is not documented so it isn’t really clear if it effects something else in the view (you can check the ImageView code if you like, i didn’t). I think the best solution is: viewToUse.setImageResource(android.R.color.transparent); I like this solution the most cause … Read more

Android XML Percent Symbol

The Android Asset Packaging Tool (aapt) has become very strict in its latest release and is now used for all Android versions. The aapt-error you’re getting is generated because it no longer allows non-positional format specifiers. Here are a few ideas how you can include the %-symbol in your resource strings. If you don’t need … Read more

Load dimension value from res/values/dimension.xml from source code

In my dimens.xml I have <dimen name=”test”>48dp</dimen> In code If I do int valueInPixels = (int) getResources().getDimension(R.dimen.test) this will return 72 which as docs state is multiplied by density of current phone (48dp x 1.5 in my case) exactly as docs state : Retrieve a dimensional for a particular resource ID. Unit conversions are based … Read more

Remove all unused resources from an android project

You can easily search for unused resources from Android Studio. Just press CtrlAltShifti and type “unused resources” (without quotes). That will execute lint. Super easy way to run lint commands (and other stuff from IDE). OR In Android Studio Menu > Refactor > Remove Unused Resources… Select the resources you want to remove. You can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)