"Expecting top level declaration" for this piece of code - android-studio

package com.example.shortvideoapp.model
data class Comment(var avatar:Int,var comment:String)
{
constructor():this(0,"")
}
How can I fix this? Any kind of help will be appreciated. Thank you.

Related

use Intent in Kotlin

When we want to move to another Activity using Intent in Kotlin, it gives this error.
In Intent, it doesn't recognize .java after ::class
look:
And when I delete .java, Intent gives an error
Note: My problem was not solved with Invalidate Caches / Restart... option in File
I don't know where the problem is. please help me.
Kinda strange because it seems good to me. Try this.
Remove the lateinit and declare it directly when you need it, maybe it will solve the problem.
val intent = Intent(this, LauncherActivity::class.java)
I don't think the this#KotlinActivity is needed in this case.
Let me know if this fix it
UPDATE
Are you sure the findViewById<TextView>... is correct ? Shouldn't it has a declaration before ? Like
val view = findViewById<>...
The solution is:
In build.gradle (:app) file, in dependencies, you should change appcompat version to 1.4.2.
befor error:
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.0'
...
}
And when I changed the version to 1.4.2, the problem was solved
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
...
}
And make sure the kotlin version is 1.5.0

IntelliJ IDEA/Android Studio - dart plugin: Missing overrides created wrong! Is this a bug?

When creating a dart file in IntelliJ IDEA with this content
abstract class A {
foo(int foo);
bar(String bar);
}
class B extends A {
}
, there are obviously two overrides missing in 'B'.
When using the 'Create 2 missing override(s)'-feature, I get this red cursor, used in the LiveTemplates, around the 'Str' in 'String'. This also changes the 'int' to 'Str'.
When changing the code slightly, it suddenly works as expected.
Did anyone encounter this issue, too?
Can anyone reproduce this issue?
Is this a problem with my settings?
Does anyone know how to fix this?
Thanks!

Why everytime open a new flutter project this error appear?

I have tried a different kind of ways to resolve the error but still can't resolve, and I'm still a new learner on flutter. But I still can run the whole project well without resolving the error shown.
There is no error that's just ide warning I think, that could be about typo etc, If you click to lamp and show us the suggestions then we can help more.
But I tried this part of code and get different warning and solved it with add # to override such as;
class MainActivity: FlutterActivity(){
#override fun configureFlutterEngine(#NonNull flutterEngine: FlutterEngine){
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
If that's show same you need to check your ide settings, probably there is a missing plugin(Dart or Flutter).

Unknown member 'SortDescriptions' on element 'CollectionViewSource'

This is a real newbie question. I feel dumb that I have not figured it out yet. I am trying to add a sort to my CollectionViewSource in my Win 8 App.
<CollectionViewSource
x:Name="itemsViewSource"
x:Key="cvs"
Source="{Binding Items}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="PubDate" Direction="Ascending"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
I have the following namespaces declared:
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
But I get the error "Unknown member 'SortDescriptions' on element 'CollectionViewSource'" when I try to build. What am I missing?
I believe that CollecitonViewSource in WinRT does not have SortDescription. You may have to order the Items instead.
This link might help as well.
A WinRT CollectionView class with Filtering and Sorting

cannot find how 'F1' key works in application

My application is built in MFC.After the application executes I need to open the help file provided with exe.
But as I press F1 application gives an error message saying the file cannot be found. This happens because no such file of that name exist.
One would think how about changing the name of help file itself? well that cannot be done I have to change the path as well.
I need to know how does the function of F1 button work and where can I find the same?
I am using VC++ 6.0 (I know its very old, but I am stuck with it).
Thank you.
To show your specific help file, you have to overwrite CWinApp::OnHelp. The path to the standard help file is stored in CWinApp::m_pszHelpFilePath. In this example, I use my own m_path variable.
void CMyApp::OnHelp()
{
::HtmlHelp(((CMainFrame*)AfxGetMainWnd())->m_hWnd,m_path,HH_DISPLAY_TOPIC,NULL);
}
If I remember correctly, by default it's handled by CWinApp::OnHelp() so take a look at your override of the application class first, you may find the ON_COMMAND handler there.
I had an class that extends CWinApp, so overwriting the OnHelp function worked this way:
In the header:
class MyApp : public CWinApp
{
public:
afx_msg void OnHelp();
}
In the cpp file:
BEGIN_MESSAGE_MAP(MyApp, CWinApp)
ON_COMMAND(ID_HELP, MyApp::OnHelp)
END_MESSAGE_MAP()
void MyApp::OnHelp()
{
// your own help function
}

Resources