• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Application Project (PopUp) Build SDK Android 2.1 (API 7)

HELPED

Lurker
I am trying to do a Popup window. But i got some errors in it. Can anyone tell me how to solve the error.



package com.example.indications;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onPopupBtClick (View view)
{
PopupMenu menu = new PopupMenu(this, view);
>inflate(error) Description Resource Path Location Type
The method inflate(int, Object) is undefined for the type Object MainActivity.java /Indications/src/com/example/indications line 22 Java Problem

menu.getMenuInflater().inflate(R.menu.activity_main,menu.getMenu());
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener());
}
public boolean onMenuItemClick (MenuItem item)
{
Toast toast = Toast.makeText (MainActivity.this,
item.getTitle() + "was pressed",
Toast.LENGTH_SHORT);
toast.show();
return true;
}
}
 
Back
Top Bottom