I'm trying direct each popup menu item to the another activity by using intent,but i get an error shown below:
This is my java code of popup menu:
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.one:
Intent i = new Intent(Cihazlar.this,MainActivity.class);
startActivity(i);
return true;
case R.id.two:
Intent i2 = new Intent(Cihazlar.this,Kampanya.class);
startActivity(i2);
return true;
}
return true;
}
});
And this is popup menu xml:
<menu xmlns:androclass="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/tools">
<item
android:id="@+id/one"
androclass:title="Senin Dünyan" />
<item
android:id="@+id/two"
androclass:title="Destek" />
<item
android:id="@+id/three"
androclass:title="Sıkça Sorulan Sorular" />
So why am i getting this error? Any help will be appreciated.
答案 0 :(得分:0)
bro have u declared it in Manifest plz post your manifest code
答案 1 :(得分:0)
the problem is not at run time. It's compile time error. So if error is like resource not found
then error is while importing R
package or error in menu.xml
.
But menu.xml
looks proper, so I think, main problem is with R.java
import. Check you have not imported com.android.R
. It should be your <package_name>.R
.
And even if this is ok, then your resources are not compiled completely. There might be some error at some other resource file (.xml file)
The very last thing one can try is to rebuild your app and then check out
EDIT
I think error is in menu.xml
file itself. Try below code, unless you have made some customize stuff-
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/one"
android:title="Senin Dünyan" />
<item
android:id="@+id/two"
androclass:title="Destek" />
<item
android:id="@+id/three"
android:title="Sıkça Sorulan Sorular" />