Android Studio - Why is this function not called? - android-studio

I'm learning Android Studio & Kotlin and came across a interesting error.
Notice how the squeezeState() is in red, or says that the function doesn't exist even though its at the bottom and has been declared properly.
Why doesn't Kotlin pickup the function reference?

I realise that this isn't JavaScript and that you need to declare the function before calling it

Related

MFC GetParent function returns null

Hello there back in 1999 early 2000 a lot of my apps used this MFC Export dialog extension which added filters to file extensions, because MFC didn't yet have that (at least that's what I remember to be the reason, maybe I was drunk I don't now), the library can be downloaded here: https://www.codeproject.com/Articles/54/Adding-filters-to-the-Open-File-dialog
Now I know that this functionality is built in already, but its easier to fix one library then to fix all of my apps
Now if I compile this with VC++ 6 everything is fine, the problem is that I would like to use a bit more modern compiler
Here are my changes that I added to this lib over the years (its a big file so I will post a link instead): https://pastebin.com/pj0j2nL4
The example code that I use to test this library can be found here: https://www.mediafire.com/file/xz5mxwy2rcmb9h3/FileExportDialog_demo_upg.zip/file
Just click on File->Export and you should see the problem
Now the problem happens on the library's void CFileExportDialog::OnTypeChange() method
is this part
CWnd *fileNameBox = GetParent()->GetDlgItem(edt1);
if (fileNameBox == NULL)
fileNameBox = GetParent()->GetDlgItem(cmb13);
For some reason, GetParent() returns NULL (I cannot even get to GetDlgItem() at this point)) pointer, I have no idea why does it do that, and the strangest thing is that this used to work on VC++ 6 (it also worked on MFC7 as well), why doesn't it work on VC++ 17 (MFC140) anymore ?
Hopefully someone has an idea what changed and how can I fix my library
Thanks for Anwsering and Best Regards

Android studio problem with configuration: type mismatach problem

I wrote a code like that:
var btn: Button = view.findViewById(R.id.btn)
view.findViewById(R.id.btn) is red underlined.
It's working fine but Android studio tolds me that it is mismatch type (Compiler expected View!). It had been working fine until i changed a profile from debug to release. Since that it show me errors.
And one more error which i recived is with:
view.findViewById<TextView>(R.id.user_name)
TextView is red underlined.
No type args expected for fun.
I belive that error s only becouse of android studio config. I can compile my code witout any problem, but android studio doesn't suggest me things like that.
Have you maybe any suggests ?
Have you tried to rebuild and clean your code? #Young_User
Might be an issue with what you are inheriting in your class.
Care to share the error code and full class too?

Where is the setting for the suggestion to wrap incompatible argument for TextView's setText() method using the static method String.valueOf()?

Recently I found out that my Android Studio no longer gives the suggestion to wrap an incompatible argument for the TextView's setText() method using the String.valueOf() method.
I sometimes forget to convert the value/variable that I'm going to pass as argument to String, but Android Studio usually gives me a warning AND suggestions to wrap the value/variable, as long as it is possible. Now, for example, when I do this:
double x = 10.567;
textView.setText(double);
Android Studio will still give me a red error warning, but the only suggestion in there is "Cast parameter to 'int'".
It used to give me the option to automatically insert the String.valueOf() method call, which is very helpful.
Is it just me or this is how it is now? There was an update a few days ago.
Did I mess up some settings in my Android Studio? Can someone tell me how to fix it?
I've looked through the Inspections settings and I haven't found it, if there's even a setting for it.
Maybe the update changes the mechanism, or you can click on the "More actions" in the prompt to see if other options available.
setText() can accept String or int, if you pass in int value, compiler will expect it is String resource ("R.string.xxx"), which is int type. Just memorize this, you don't need to rely on the prompt any more.

wxwidget overloaded functions "wxToolbar::Addtool"

Good day.
I'm working on a GUI application using WxWidget in Visual Studio 2017. I've encountered this error:
No instance of overloaded functions "wxToolbar::Addtool"matches the
argumentlist argument are: (wxStandardID, wxBitmap,conts wchar_t[17] object type is : wxToolbar)
I had managed to bring down the errors from twenty-five to six, but the error above doesn't go away
(I've claned and restarted my IDE). The code below is where the issue is occurring:
wxToolBar *toolbar = CreateToolBar();
toolbar->AddTool(wxID_EXIT, exit, wxT("Exit application"));
toolbar->Realize();
It looks like the Wxwidget version you are programming with is >2.9. Looking the documentation,
the method for parameter overloading : toolbar1->AddTool(wxID_ANY, save, wxT("")); had been deprecated, would advice you study this before you start coding.
Happy coding.

Android Studio ambiguous method call for Object.toString

Others have seen the "Ambiguous Method Call" error in Android Studio for
getClass()
But I'm seeing it for
Object.toString()
Has anyone else seen that?
The version of Android Studio I have is 0.8.6.
First off, to answer your actual question, yes I am seeing that, and I am running Android Studio (Beta) 0.8.14, and it is an Android Studio/IntelliJ bug, as mentioned before, so your code should be fine when you actually compile. But, if you want it to stop underlining everything in red:
As you may notice on the issue of the getClass() call found at Android Studio - Ambiguous method call getClass(), you can cast the object in question to an Object to resolve it as such:
((Object) myObject).toString()
Alternatively, depending on the case you're dealing with, you may be able to rely on Java's included libraries implicitly* calling toString() on the object, as was the case with my code, where I was appending to a StringBuffer:
sb.append("Object's toString() returned: " + myObject);
Note: this will still work even if you didn't have the literal String object that I defined there, so this is also valid:
sb.append(myObject);
Or if you're simply printing to standard out,
System.out.println(myObject);
*As a side note, it is not actually being called implicitly, but rather many of Java's built-in classes have an overloaded method signature that accepts objects of type Object, which is then turned into a string via a call to String.valueOf(myObject) - see How an object will call toString method implicitly? for more about this.

Resources