First, edit attrs.xml to include the name: <attr name="undo_icon"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="undo_icon" format="reference" />
</resources>
Then, edit the styles.xml to define the style: <item name="undo_icon">
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppThemeLight" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="undo_icon">@drawable/halo_dark_content_undo</item>
</style>
<style name="AppThemeDark" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="undo_icon">@drawable/halo_light_content_undo</item>
</style>
</resources>
Finally, define the menu.xml: android:icon="?undo_icon"
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_undo"
android:icon="?undo_icon"
android:title="Undo"
android:titleCondensed="Undo">
</item>
</menu>
In the Manifest: android:theme="@style/AppThemeLight" > OR switch dynamically via Context.setTheme
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppThemeLight" >
To reference in code:
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.undo_icon, typedValue, true);
btnUndo.setImageResource(typedValue.resourceId);
Friday, August 29, 2014
Thursday, August 28, 2014
How to fix Android SDK Content Loader stuck at 0% in Eclipse
Have you encountered the case where Eclipse hangs upon startup, in
particular when you are developing an Android applications with Android
SDK?
When that happens you see "Android SDK Content Loader" stuck at 0% in the bottom right hand of the Eclipse status bar.
There are four things you can try...
Go to your workspace directory
When that happens you see "Android SDK Content Loader" stuck at 0% in the bottom right hand of the Eclipse status bar.
There are four things you can try...
Solution 1:
Solution 2: (Works best for me, and likely the safest)
Solution 3:
Solution 4: (Most drastic, and one I have not tried)- Make sure that eclipse is not active. If it is active kill eclipse from the processes tab of the task manager
- Check if the adb process is running. If so, kill the adb process, and restart Eclipse.
Solution 2: (Works best for me, and likely the safest)
- Make sure that eclipse is not active. If it is active kill eclipse from the processes tab of the task manager
- From the command line run: C:\eclipse\eclipse.exe -clean
Solution 3:
- Make sure that eclipse is not active. If it is active kill eclipse from the processes tab of the task manager
- Open %USERPROFILE%/ (You can locate this folder from desktop) (or paste it into Explorer on windows)
- Go to .android folder (This may be a hidden folder)
- Delete the folder "cache" which is located inside .android folder
- Delete the file ddms.cfg which is located inside .android folder
- Start Eclipse
Go to your workspace directory
\workspace\.metadata\.plugins\org.eclipse.core.resources\\.projects
- Copy
.projects
folder to make a temporary backup. - Now Delete
.projects
folder from workspace directory. (you will not loose your projects) - Start Eclipse and wait for all progress ends at right/bottom corner. Once completed all processes, shutdown Eclipse.
- Paste
.projects
folder which you have backup earlier to\workspace\.metadata\.plugins\org.eclipse.core.resources\
directory. Overwrite existing.projects
folder. - Start Eclipse again. And all will work.
Good Luck
Subscribe to:
Posts (Atom)