Android custom keyboard - Class not found (XML) - android

What i want to do:
Create a custom keyboard, since default keyboards are not sufficient.
Keys needed: 0-9, '-', ',', 'e', 'del' and one empty one where i can put the logo.
I already achieved this in iOS with inputAccessoryView, but after some research i believe there is nothing similar in android. So i decided to go the way of creating my own Keyboard in xml.
Tested Source is from here.
But the XML Designer in Android Studio tells me: The following classes could not be found:
Keyboard (Fix Build Path)
Row (Fix Build Path)
Tip: Try to build the project.
I have no clue what this error is about, and stated tips by android studio aren't doing anything.Any help is appreciated!
EDIT: Ok, to make it clear: Android Studio doesn't know the xml tag "< Keyboard >". Why? Do i need some sort of special import in the manifest file? or sth in the gradle files?
EDIT 2: To make it really clear what happens to be my problem here:

It is possible to do a custom keyboard!
The Keyboard design must be in res/xml/qwerty.xml.
I would recommend you to follow this tutorial, where it is explained how to do it from scratch.
Good luck and hope it helps! :)

Related

How can I make code beautiful in Android Studio as like as VSCode?

VSCode have a great option what helps developer to make code more beautiful. I mentioned in the given picture. It indicates each brackets related to which case. I've worked on flutter in VSCode but now I've decided to work on Android Studio for some reasons and unfortunately I don't know where I can find it. Did you guys know how I can fix it?
I have to apologize for Title because I don't know what this option is?
You can also use following command to make more beautiful and easy
(1) Search Everywhere (Press Shift Twice / Press Shift Twice)
(2) Recently Opened Files (CTRL+E/Command+E)
(3) Find Action (CTRL+Shift+A/Command+Shift+A)
(4) Generate Code (ALT+INS/Command+N)
(5) Override Methods(CTRL+O/Command+O)
(6) Delete Line at Caret/Cursor (CTRL+Y/Command+Y)
(7) Collapse/Expand Code Blocks (CTRL+- / Command+-)
(8) Collapse/Expand Whole activity code (CTRL ALT - /CTRL ALT +)
(9) Reformat Code (CTRL+ALT+L / Command+Option+L)
Just Press CTRL+ALT+L on Windows or Command+Option+L on Mac. The android studio will reformat all the code for you. And the good part is that it works for XML layouts as well.
Use CTRL+ALT+L to reformat your code.
Use CTRL+ALT+O to optimize imports.
Use CTRL+ space to complete code.

Which format Android Studio default code style scheme follows?

If you go to: Android Studio -> Preferences -> Editor -> Code Style -> Java/Groovy/XML you find Default Scheme.
Or on MacOS: /Users/raiym/Library/Preferences/AndroidStudio3.1/codestyles/Default.xml
Where it comes from? Couldn't find which style guide Android Studio follows.
I've done quite a lot of researches, but in the end, I haven't reached a very satisfying answer: probably it's just a code style for IntelliJ.
The first thing I did was trying to compare the IntelliJ style with something else, but I always found some differences.
It doesn't follow Google's style because they don't fully qualify import, in fact, IntelliJ will try to unify imports by putting *, like writing import foo.*; instead of import foo.Bar;.
It doesn't follow Oracle's guidelines either since the switch statement is formatted in a different way:
switch (condition) {
case IDEA:
statements;
break;
case ORACLE:
statements;
break;
}
At this point, I've started looking for something else, but found even less. In fact, IntelliJ doesn't tell about the code style used in their software anywhere. Instead, they just explain how to change it.
Moreover, there are plugins for every possible code style! If one of them was the actual style in IDEA a plugin shouldn't be needed...
To make things worse, even for Kotlin, a language created by IntelliJ, they differentiate between "Kotlin Coding Conventions" and "IntelliJ IDEA default code style".
What I think is that they made a code style that works for most languages supported by their IDEs with little differences, and this is what Android Studio ended up using by default.
Android Studio code styles are based on IntelliJ Idea code styles. You can refer this link to know more about code styles in IntelliJ Idea
Code Style Java
Also you can refer this link to customise your code styles,
Android Studio Code Style

Annoying default formatting

I am working on a simple android application in eclipse IDE and I got a little yellow icon on the left hand side of a line of xml code that looks like a light bulb with an exclamation mark beside it. When I hovered over, it says "[I18N] Hardcoded string "input..., should use #string resource input". The running and debug was successful but I just want to get rid of it as I find it annoying. What should I do?
If it's annoying, there is a reason. You totally should use #string resources instead of your hardcoded strings. All you have to do is to put your string in res/values/strings.xml and reference it in your layout via #string/my_string_id_here.
This is extremely useful for multi language support, or for plurals strings.
You can learn more here.
Hope this will help you.
The right way:
Move all your strings into resource files, as suggested, and reference them in your views like so: #string/mystringname
The "other" way:
Turn off Lint warnings in Eclipse in Window/Preferences/Android/Lint Error Checking
Both ways will remove that annoying triangle :)
This warning is there because hardcoding strings into the android app's Java source code is not recommended. It will compile fine - but Android Lint will complain about it, so that's why it's a "warning" and not an "error". Generally, it is preferable to define them in the separate "string.xml" file.
If you want to know why, check this answer.
For an example, check this answer.
You should also take a look at the official documentation for string resources.

Know if resource image is used

Is there any quick way to know if an image is referenced or used in a Java class or XML layout? For example like if an image.9.png is used in a certain layout. Thanks.
in Eclipse you cam make Search Like below Step .
First Click your Current Project in which you would like to Search .
Now Press Ctrl+H in windows that will open Search Dialog Window.
Now you want to check bg.png used in your Project ,Search like below in
#drawable/bg
This will search for all Layout and xml file which use this image.
Now for Search in java file you need to search with it's id which you give in xml file.
R.id.yourimageId
Now in your case you can search your #drawable/image by Ctrl+h Dialog in Eclipse.
EDIT In ADT updated version Like ADT 16 we have lint tool it will give all warning for unused Resource .
Issue: Looks for unused resources
you will find this warning in lint check .
for More about Lint Refer this Link Lint Checker SO
There's no way to do it via code. However, in Eclipse, if you delete the image (make sure you make a copy first) and build the project, you'll know the spots where you are missing it :)

Any possibility to get autocompletion / type-ahead / intellisense in Android XML Files (Eclipse)

Is there any way to make Eclipse + Android SDK + ADT Plugin offer some sort of auto-complete in XML files if I hit CTRL+Space when my cursor is in a spot such as the ones marked with an * below.
<LinearLayout id* ... lay*>
The thing is that I think that the above was actually working already directly after the initial install - even though it of course never worked within style files.
<style name="ActionBarWrapper" parent="Fill_Parent.Vertical">
<item name="android:layout_height">36dp</item>
<item name="a*"
</style>
There is an icon in the eclispe toolbar to directly access the "new android xml file" wizard.
You could use IntelliJ IDEA instead of Eclipse, it has full auto-completion and works well for Android development.
http://www.jetbrains.com/idea/
The Community Edition fully supports Android, and is FREE
The latest ADT plugin (r9) does have partial auto complete feature in the layout xml.
for example, if you type ctrl-spacebar while the cursor is between 2 tags, you get the list of all avaliable tags (views and layouts). If your cursor is inside a tag, you get a list of all avaliable attributes.
First of all: Thanks for the good advice everybody. Not sure if the following should be an answer or a comment. Going for the answer because comments do not allow enough characters.
After trying out some eclipse plugins (like Rinzo XML Editor ) I found out that it actually worked for some files while it did not work at all for others. After some testing I am now under the impression that there is a difference between creating XML files via...
New > XML
and
New > Other > Android > Android XML File
I double checked that even when both files have exactly the same content (xml-version, encoding, namespace etc.) they behave differently with regards to auto-code-completion depending on the way of file-creation. I also checked the file properties but could not make out any significant differences. Obviously it must be something local or some meta stuff I am overlooking.
I think the different behavior is because when you create the file using "New->XML" the wizard opens the file using the default associated editor to xml content.
If you create a file using "New->Other->Android->Android XML File" I think the wizards tries to open the xml file using a specific xml editor, instead of the one you have configured as default, in this case Rinzo I guess.
In the second case why don't you try finding the xml file in either "Package Explorer" view or "Navigator" view, right click on the xml file and selecting Rinzo through the "Open With" option.

Categories

Resources