removing some features from settings menu in android app - android

I am developing an app with an open source code and I want to completely remove the feature of "Linked Devices" which is in settings.
I tried by deleting the string name from strings.xml file and by deleting the android:label from androidmanifest file. But it only removes the name and the feature is coming like this #2343243545 and if we click on this option the app is getting stopped.
Suggest me something to remove this completely.
Here is the link to the open source code on which I am working https://github.com/WhisperSystems/Signal-Android/tree/0a569676f7a57144374a24faef566b2ca3233290

If your intent is to remove menu item, you can find menu XML files under res/menu directory inside project files.
Look for <menu> and delete <item> or <group> tag that you do not need.

If the settings activity/fragment extends either the PreferenceActivity
or PreferenceFragment class, the drawing of the screen is driven by a file in the res/xml directory. In this case, you will need to remove the Preference (Preference, CheckboxPreference, ListPreference, EditTextPreference, etc.) defined in a file that belongs to that path. It is likely named preferences.xml.
If this is not the case/what you are looking for, please share the code that you are dealing with.

Related

Android Studio: How to add a definition to a file

Android studio beginner here. My professor is telling me to change the res/values/strings.xml in my application. The purpose of this is to add a Color definition to the file and then tells me to press an "Add" button. However, I'm having trouble actually accessing the same window he is...here is the window:
What I see when opening the strings.xml file is this:
There are no buttons for me to actually add a definition. I tried playing around with the strings.xml file by right clicking the file, but nothing really looks like anything I want.
Any help is appreciated!
My professor is telling me to change the res/values/strings.xml in my application.
Here you mention that you want to change the strings using Add button. In that case, you can do it as follows:
Click on Open Editor on the top right when your strings.xml is open.
Then you will see this new Window. Use + key to add a new string resource.
Your professor might have a different Android Studio version. This is how it shows in Android Studio 2.3.3 version.
The purpose of this is to add a Color definition to the file ...
Here you mention that you want to change the color definitions. If that's the case, you need to change in colors.xml. If a file is not there, then create one in values folder and add <color name="color_name">#HEX_VALUE</color>. Then you can reference the color from Java or XML file.
Just add another entry in your strings.xml file corresponding to what your requirement is, and save the file.
For example:
<resources>
<string name="app_name">Temperature Converter</string>
<string name="new_string_name">new_string_value</string>
</resources>

Is it possible to open the Translation Editor using a different xml instead of strings.xml?

I have my strings stored in different .xml(s). Now, I need to do some translations for them and I was wondering if it is possible to open the Translation Editor for those xml. I tried but it only appears on the strings.xml
Your help will be greatly appreciated.
This is old, but I figured something out that may be helpful for anyone looking.
When you open the Translations Editor for a module, it will show all strings in the res folder, not just the "strings.xml" file. So if you have other .xml files with strings, they will be listed.
The Android Studio UI only allows the Translation Editor to be opened from the "strings.xml" file. So if you have a module that has strings files without any xml file named "strings.xml" just create a blank "strings.xml" file in that res folder and use that to open the Translations Editor - it will list all strings.
If I understand this correctly, you don't need to open separate files in translation editor.
Open your something.xml file
Alt + Enter on any item -> Override resource in other configuration
Select Locale and press the button ">>"
Choose locale needed.
This will create localization file for your something.xml file.
something.xml -> copy all innards -> paste into localization file.
If you remove all values from localization file, and than open your main strings.xml file with editor, you will find there the words from something.xml untranslated. If you won't, you will find similar values for original and new locale.
When you open in editor your strings.xml, Studio puts there all string resources from the current module, despite you put your strings in multiple files. Maybe this is not as handy, as it would be with opening files one by one, but this still good, if you just need to make sure you didn't miss any string to be translated.
Open any layout
Find this panel by image panel
Click on earth icon
Click "Edit translations"
I have pretty big translation database, almost 1k positions on every single language. And every module has its own prefix, so my string files look like this: prefix_strings_hitory.xml, prefix_strings_news.xml, prefix_strings_coutries.xml etc. Android Studio translation editor can't handle properly translations with files different than strings.xml.
That's how am I doing this:
1.In every module create empty file strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
Thanks to this you can open editor easy.
2.Now assume you want to have file named values/abc_strings_main_activity.xml, create it.
3.When we need german translation, you have to manualy make a copy of your original (default) file: values-de/abc_strings_main_activity.xml. If you let Translation Editor copy your file, it would create values-de/strings.xml instead and put your strings there.
4.Now when you use Translation Editor, it would be properly saving your string in correct files and positions.
5.When I make a copy of my file, I always use file with empty tags body, e.g.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="abc__button_1"></string>
<string name="abc__tile"></string>
<string name="abc__share"></string>
</resources>
Thanks to it, I can see empty (not translated) cells in Translation Editor
I'm using Android Studio 2.3.3
Opening the "translation editor" window I've realized that all entries from different resource file (strings.xml, otherTranslationFile.xml and so on...) are listed.
In the example I've used a prefix "c_" to better sort and recognize that specific entries

Android Development: Unable to create an icon #drawable/ic_action_search

I am new to Android Development. I was just following the basic turorial on developer.android.com to create my first application.
As I was creating the Action BAr, I had to add this Search button to it. I created the menu xml and this is what I had written on it.
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
Now my question is on this part of the XML
android:icon="#drawable/ic_action_search"
I get a compilation error in eclipse, which says,
error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_action_search').
I checked on developer.android.com and also googled it out, but I'm just not able to locate a solution.
I need to solve this problem. As always, I am able to skip this part of the XML and what I get is just plain text "SEARCH", but the icon will definitely look better.
Here is the easy way if you're using Eclipse:
Ctrl+N (emacs keybindings) to open the file wizard
'File | New | Image Asset' in Android Studio
Select Android, "Android Icon Set"
Edit name ic_action_xx, click Next
Clipart, choose the icon you want
Select theme (Holo Light means a light background, Holo Dark means a dark background)
Eclipse will automatically populate the res/drawable-* directories with the new icon, scaled to the directory size. No need to download anything, understand PNG or copy the icon into multiple directories.
I use the file wizard A LOT.
In Android studio:
Right click the Drawable folder > Select New > Image Asset
(Alternatively, click shift, shift and type 'Image Asset")
In the dialog which popped up click 'OK'
From the wizard you can customise the asset you require.
Choose if it's a Notification icon, Action bar icon or launcher icon. You can select icons from clipart, create icon from text or import an image from disk.
The wizard will take care of creating different resolutions for your new image.
You need an image called ic_action_search.png or ic_action_search.gif, for example. Paste this image in every res/drawable folder.
As others have advised, you need to have (put) the icon graphic, "ic_action_search.png" in the correct folder, which is "/res/drawable" You may have to move a graphic file for one or more of the "drawable" subfolders of "/res"
You can find the icon graphics (and others that you will, presumably, need in the future) at, (http://developer.android.com/design/downloads/index.html#action-bar-icon-pack)
Please note: do not use the "Core Icons/unstyled," in the package. Use the "All_Icons/holo_light," (most likely) or "All_icons/holo_dark."
The error means that you don't have an image called ic_action_search in your drawable folder.
You can download an image for search from Android Asset Studio if you like.
I suppose you copy pasted some example code, as other answers says you missed putting drawable into your resources. For testing you might use default android search icon:
android:icon="#android:drawable/ic_menu_search"
I am not sure if it is safe to use it in release apps
First think English is no my main language, i apologize for my typing. Ok let's go to the problem. All this works for me, i hope it works for you. I was following the same instructions from developer.android.com as you, and it didn't say that you have
to put it in both .xml, or i didn't see.
Because is too much stuff and is overwhelming, i know at first but i hope to get used to it soon. Under the folder: res/menu you have two.xml archive one for the main page and the other for the activity. What do you have to do is copy that you wrote to both .xml archive:
Display_message.xml
main.xml
remember the action bar goes along the way with the activity, as many as you have. That means if you add another activity, you have to paste this in the new one in order to void that error. By the way you already have the images int he their respective folder. if not, it going to pop the error again. I hope this was understandable and with sense.
An other way to add a new icon into your project in Android Studio (same as dturvene's in Eclipse)
1. Choose drawable directory; Alt + Insert or File/New...
2. Choose "Image Asset"
3. Select drawable\hdpi as your icon's destination
4. An option window will pop up. Select directory to your icon saved in your PC.
I just found the way to do it so I hope it help.

Unable to add Preferences.xml (Android Preferences in XML)

Hopefully, this is a newbie question with a quick answer...
I am attempting to add a simple preferences file in a new Android project (New -> Android XML File), but it doesn't appear to be working correctly.
There is no root element to choose from when I select the Preference type layout. If I press Finish, it doesn't do anything. See screenshot below.
Thanks,
wTs
Just create a normal xml file to the project /res/xml/ folder and add your content to the file as usual. Should work just great. Eclipse detects it as a preference file once you have added the preference-xml and saved it.
You don't need to have a root element in the selection screen. Just replace whatever eclipse generates with what you want.
try refreshing the folder that the file is supposed to be in (in your example res/xml).

Is it possible to set an android icon from a drawable in a separate jar?

I want to set a menu option icon for a drawable that is in another jar inside an xml file.
<item android:id="#+id/my_location"
android:title="My Location"
android:icon="#+drawable/my_location">
Instead of drawable/my_location have something like com.somelib.R.drawable.someDrawable.
I can set this in onCreateOptionsMenu but was just wondering if it could be done via the xml file.
I want to set a menu option icon for a
drawable that is in another jar inside
an xml file.
Drawable resources cannot go in JARs. You are welcome to store images in a JAR and deal with them outside of the resource framework.
I can set this in onCreateOptionsMenu
but was just wondering if it could be
done via the xml file.
No, because, again, images in a JAR file are not resources, defined as images in res/drawable-*/ in your project. Sorry!

Categories

Resources