calling onOptionsItemSelected explicitly

I have a Save MenuItem. This has a onOptionsItemSelected(MenuItem item) function. It's triggered when I click on the Save menu. However, I want to call this function explicitely when the user tries to navidate to another activity without saving. So basically how can I call this onOptionsItemSelected(MenuItem item) from another function?

Answers


Do one thing all the code you written in this method within for save just copy and paste in you created method for e.g.

onOptionsItemSelected(MenuItem item){

    switch(item.getItemId()){
    case R.id.save:
       saveMe();
    break;
    }
}

private void saveMe(){
    // write your save code here
}

now you can call this method when user navigate to another activity


Need Your Help

ExtJS - Open tab through clicking on link in GridPanel (column renderer)

hyperlink extjs grid listener renderer

I created link in the grid panel, so that when I click on the link and it will open another tab in the tab panel. Currently I render the column cell output into html href with onClick event. But it...

Editing PDF with XPDF (or with something else)

c++ pdf editing xpdf

I would like to ask if it is possible to edit PDF files using the xpdf library and if yes how? I guess this is possible but i could not find any tutorial nor documentation for xpdf so i have realy no

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.