Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 71

Fiona@MGT
Aspiring developer
Profile
Posts: 3
Reg: Dec 07, 2012
EUGENE
30
04/08/13 10:16 AM (12 years ago)

Linking to existing screens from Android options menu/action bar

Hi, I think this has been asked before but not answered that I could see. I am trying to customize the menu that comes up on Android when the menu key is pressed (currently it just says OK close). What I would like is to make buttons that would link to the home screen of the app (a menu Buttons screen) and to the settings page (a Menu List screen). I have found the source code in eclipse that is creating the menu I am just not what sure I would put into the public void onClick(View v){ } portion in order to call the screens. Thanks for any help. Fiona
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
04/08/13 10:50 AM (12 years ago)
Hi, If you want to add any options in the menu of the app on the Menu Button plugin then you will have to put all the relevant codes below the following line which is line number 1139 and not in line 1169 ( which is - public void onClick(View v){ )- @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); You will have to provide an intent for each option item you want to link another plugin. For example you want to link an option to a custom html plugin screen then put following code- case R.id.customHTML: if (!thisClassName.equals(thisPackageName + ".BT_screen_customHTML")) { i = new Intent(this, BT_screen_customHTML.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); return true; Hope this helps you...
 
Fiona@MGT
Aspiring developer
Profile
Posts: 3
Reg: Dec 07, 2012
EUGENE
30
like
04/08/13 11:36 AM (12 years ago)
I am not sure I understand entirely. I have set up extra buttons in the menu eg. final Button btnHome = new Button(this); btnExit.setText(getString(R.string.Home)); btnExit.setOnClickListener(new OnClickListener(){ public void onClick(View v){ } }); options.add(btnHome); But I am not sure how I would implement the code you suggested in order to have the button link to the correct screen. Thanks
 
Fiona@MGT
Aspiring developer
Profile
Posts: 3
Reg: Dec 07, 2012
EUGENE
30
like
04/11/13 10:09 AM (12 years ago)
I got it working. In case anyone else is having the same problem the solution I found was: btnName.setOnClickListener(new OnClickListener(){ public void onClick(View v){ dialog.cancel(); BT_item ScreenLoadObject = appname_appDelegate.rootApp.getScreenDataByItemNickname("ScreenNickname"); BT_act_controller.loadScreenObject(thisActivity, screenData, null, ScreenLoadObject); } }); options.add(btnName);
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.