Error:(45, 43) error: no suitable constructor found for Intent(,Class) constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; cannot be converted to String) constructor Intent.Intent(Context,Class) is not applicable (argument mismatch; cannot be converted to Context) Error:(51, 44) error: no suitable constructor found for Intent(,Class) constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; cannot be converted to String) constructor Intent.Intent(Context,Class) is not applicable (argument mismatch; cannot be converted to Context) Error:(57, 43) error: no suitable constructor found for Intent(,Class) constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; cannot be converted to String) constructor Intent.Intent(Context,Class) is not applicable (argument mismatch; cannot be converted to Context) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Menu.java public class Menüsü {
ListView lv;
private static String[] menu_list = { "list one", "list 2", "list 3" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
listview();
}
public void listview() {
lv = (ListView) findViewById(R.id.lv_Menu_List);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.list_layout, menu_list);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// String value =(String)lv.getItemAtPosition(position);
if (position == 0) {
Intent intent = new Intent(this, ListOne.class);
startActivity(intent);
} else if (position == 1) {
Intent intent = new Intent(this, List2.class);
startActivity(intent);
} else if (position == 2) {
Intent intent = new Intent(this, List3.class);
startActivity(intent);
}
}
});
}
}
activity_menu.xml
AppCompatActivity uzanır<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.examplemenu.Menu">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lv_Menu_List"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
list_layout.xml
<xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:soundEffectsEnabled="true">
</TextView>
bu satırı değiştir Intent intent = new Intent (this, List2.class); Niyet amacı = yeni Niyet (Menu.this, List2.class); – Killer
'bu' geçerli bağlamı döndürün ve burada bunu içsel bir sınıf içinde kullanıyorsunuz, bu nedenle 'bu' Menu.class (Activity context) bağlamında AdapterView sınıfının bağlamını verecektir. – Killer