I have been trying to learn through following YouTube tutorials. I am using Android Studio 3.1 Canary and I get to the same point in the tutorials and get stuck. For instance if you go to this YouTube tutorial https://youtu.be/3RMboPhUbmg?t=210 at the 3:30 min mark.
When they are inputting the MaterialSearchView searchView; it shows up for me with a red underline saying "expecting member declaration" and no matter how many searches I try I cannot find an answer. What is the solution to this error? Thanks
This is the code contained in the Main2Activity.kt. The result should be calling or knowing the toolbar and materialsearchview objects
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.Toolbar
import com.miguelcatalan.materialsearchview.MaterialSearchView
import kotlinx.android.synthetic.main.activity_main2.*
class Main2Activity : AppCompatActivity () {
**MaterialSearchView searchView;** "expecting member declaration error"
**Toolbar toolbar;** "expecting member declaration error"
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
toolbar=(Toolbar()) findViewbyId(R.id.toolbar);
setSupportActionBar(toolbar);
}
*private void searchViewCode()
{
searchView=(MaterialSearchView)findViewById(R.id.search_view);
}
}