Vote count:
0
I am using a Tabbar in my MainActivity. The tabbar has two tabs. When the tab will change, the menu will also change. So when I am in the "Recommendation" tab it will have the menu item "Refresh".
This is from my MainActivity class.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
if( tabHost.getCurrentTab() == 0 ){
menu.clear();
getMenuInflater().inflate(R.menu.watchlist_menu, menu);
}else{
//recommendations
menu.clear();
getMenuInflater().inflate(R.menu.recommendation_menu, menu);
}
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
//super.onOptionsItemSelected(item);
switch( item.getItemId() )
{
case R.id.addItem:
//
startActivity( new Intent( this, AddActivity.class ) );
return true;
case R.id.refreshItem:
//REFRESH FUNCTION SHOULD BE CALLED NOW
return true;
}
return true;
}
The RecommendationActivity class has a function called refresh which I want to call when the refreshItem has been clicked. But how do I do that?
asked 1 min ago
1 Answer
Vote count:
0
Create a class object and use its Function.
RecommendationActivity test = new RecommendationActivity();
test.refresh();
answered 46 secs ago
Aucun commentaire:
Enregistrer un commentaire