Content_Main and Activity_Main in Android Studio 1.4: If I put a button in activity_main, but not content_main, will the java file know about it? - android-studio

I'm a beginner to android but have done a little with an older version of Android Studio, and in the new version I'm having a lot of trouble getting the java file to find buttons or ImageViews. I'm not sure if it's related to the content_main vs activity_main thing. I'm having trouble finding any answers as to how this works on Google, so I'm just starting here, I want to put a button on the main page of my app and have the java file that correlates to the XML file find it. How do I do this?
Answers online are very vague to me, things like "activity_main.xml will determine how the look of the main activity should be. And on the other hand content_main.xml will determine the contents in the activity_main.xml" does not mean anything to me. Please tell me where to put the button!

If you are adding a button in activity_main rather than content_main it cannot be recognized by your Java file. Not only that is will even not be visible on your app.

Related

Why does the syntax color code of Visual Studio Code act weird on me?

I am using Visual Studio Code 2022:
Information on my VS code version
Up until now, I have had the colors appearing correctly in the default theme of VS code Dark+ (default dark).
I am currently using it for unity, so for C#, but sometimes use it for HTML CSS.
Those are the extensions that I have currently installed:
List of Extensions
I just noticed recently that right after clicking on a different .CS file, the color code doesn't work anymore. I can't figure out why, but it's super annoying. Classes used to be green, and their names used to be blue. Now, they are All blue.
Here is what it looks like when things are working fine:
Working Fine
And this is what it looks like as soon as I click on another .CS file in the file explorer:
Not Working
The only way to get my colors back, is to close VS code and re-open it.. but it's useless because I am eventually going to select a different .CS file in the explorer, and the problem arises again.
I have been coding for only 4 months, so forgive me if this is actually something simple, but I could not find the exact same issue somewhere else.
Thank you!

visual layout editor does not allow drag&drop

I'am a newby in android studio and learning a lot, but now have a problem where i cannot seem to find the answer to.
In android studio you can visualy drag&drop your screen.
I have seen it can do al lot (although you sometimes need the xml) but for me it is not working at all.
I mean i cannot drag&drop any widgets on the screen at all.
Tried changing the theme: no help (really tried a lot of them)
Tried a complete new project: same story
Tried other APK verion: same story
Tried Invalidatd caches / restart: no help
Even with a new project (EmptyActivity) it add's a android.support.v4.widget.NestedScrollView and then gives error's on that
(Failed to find style 'coordinatorLayoutStyle' in current theme).
It also gives an error on layout_height/layout_with not being there. But they are there for each widget.
Please do not missunderstand: when i execute the project i runs just fine (both on phone and emulator) but the visual builder for the screen.....:-(
Does somebody knows how to solve this.
If more info is needed please ask.
Any help is more than welcome.
There are several things that could be causing this:
Your caches could be messed up. Try going to
File > Invalidate Caches / Restart ... (I know that you already tried this, but posting for future views.)
Also, make sure that you don't have Drag-n-Drop with ALT pressed only checked in your Settings (Appearance & Behavior - Appearance).
Finally, in a default project created in Android Studio, there are two XML files created for each layout. For example, content_main.xml is embedded within activity_main.xml. Make sure that you are using content_main.xml for your design work.
In the end i fixed it by changing the SDK version in de gradle file.
still do not understand why it was wrong as studio genereded it that way but now it works so.... for me: case closed.

javax.microedition.io.file does not exist in BlueJ

Trying j2me app development. I got a simple Hello to work, and a simple TextBox user as well. But when I tried to compile code for a file browser I got "javax.microedition.io.file does not exist".
The WTK according to the Sun website is supposed to include JSR75. And there's a camera demo .java file that uses it.
I've looked in various places (the WTK, BlueJ, even Netbeans) for menu options to turn it on. Nothing. And a search of this forum turned up exactly ONE message and it pertains to another IDE, and it seemed to work for him in BlueJ.
So what am I missing and how do I get it?
In NetBeans, you go to Project Properties (right-click the project, and select Properties). Then click "Platform" and mark "File Connection and PIM Optional Packages 1.0".
On a whim I did a search for JSR75 jar download and found a few zipped jar files that seemed to contain the file classes. I unzipped one of them and put it in the Libraries/Userlib directory of BlueJ; and now I seem to have the File... Classes. Reading and writing seem to work in the emulator.
I'll take another look at Netbeans when I get a chance.

Android Studio Plugin - Show Image In Editor

I'd like to be able to display an image below a class-level javadoc in Android Studio. My assumption is that I should write a plugin to make this happen.
Does anyone know what I need to do to get an image (JPEG or PNG) to display below a class-level javadoc comment in a Java class file?
I looked into basic information about creating an IntelliJ IDEA plugin but I have no idea where to look to accomplish my task.
This is not possible in the current version of IntelliJ IDEA. The editor can display only text, and does not support embedding of non-text things such as an image file.
You can display images on hover, or in popups, or in dialogs, but not within the editor itself.
Do you want the image to show in the class' source code itself? As an aside, images in Javadocs will show when you view the formatted javadoc view the Quick documentation action (Windows/Linux: Ctrl+Q or Mac: ^J)
If you still want the image to show in the source code, then yes, you will need to write a plug-in. You can look at the Information for Plugin Developers
Setting Up the Plugin Development Environment section of this web page - https://www.jetbrains.com/idea/plugins - to get started. You'll have to dig through source code to try and find some ideas for how to display an image in the source code. As much as I love IntelliJ IDEA, there plug-in documentation is a bit weak. When I wrote a plug-in, I had to do a lot of looking through the IDEA code to find code that was doing things similar to what I wanted to do. I also downloaded the source code for some of the better plug-ins out there and looked through them.
Finally, you can ask for some guidance in the IntelliJ IDEA Open API and Plugin Development forum. That forum is monitored by JetBrains developers. Your best bet to getting answers in that forum is to ask very specific questions. Do not try and get someone to explain from start to finish what you need to do. As you do each step, ask questions about what you are trying to do.

Getting started with Xcode 4.2

I have recently got a Mac and I have downloaded Xcode 4.2 from the store. I am trying to get to grips with iPhone development but I am having real troubles. All the tutorials I seem to find online, when they create a project, they had a resources folder, and inside that there is xib file which allows them to use an interface builder.
This does not appear on 4.2, so makes it kinda hard to follow majority of tutorials have the resources folder. How do I get this back? Or how do I access this file on 4.2?
Also, I could someone explain to me where the objects list is? I started following this tutorial
http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/
as it seemed to be using Xcode 4.2, but when I get down to the storyboard section, it says
"Of course, we really want another tab on there so we can see the switching between the two – so lets drag in another Navigation Controller from the Utilities (objects) list and plonk it down somewhere. "
Except I cannot find this objects list? How do I open this objects list? What am I missing?
Sorry if these questions seem very basic, I am new to both Macs and iPhones. Android development seems a HELL of a lot easier from what I can see so far.
Thanks in advance for any help.
Also would be grateful if anyone could point in direction of any good up to date tutorials
I have a post on http://www.armandvanderwalt.co.za it will give you a nice understanding of how most stuff fits together, I don't use Interface Builder at all since it only makes the app bigger. Have a look at my blog post, still need to do styling, and add more posts but it is a nice beginner guide.
Most posts you are finding still use XCode 3 that's why you can't find certain things.
Also have a look at http://www.raywenderlich.com
What they are referring to as the object list, in XCode 4 it is found in the bottom right corner of Interface Builder. In XCode 4 Interface Builder is part of XCode and no longer an external application. Therefore when ever you open a XIB file Interface Builder also automatically opens

Resources