不同的Android设备偶尔会有不同的屏幕功能(例如点亮火灾应用中屏幕底部的按钮)。你怎么能改变这种按钮的行为?我找不到任何资源来做这样的事情。
**编辑**
我发现我所谓的“底部按钮”更适合称为来自亚马逊的某些Kindle Fire文档的Options Bar
**编辑**
考虑到两个答案都说不可能,我决定是时候举个例子了。看起来我想要制作的菜单实际上是应用程序的一部分,但是有一个用于这些系统按钮的按钮监听器。如何查找使用这些按钮的示例代码?
答案 0 :(得分:2)
如何更改这些按钮的行为?
您询问相关设备的制造商如何修改他们在Android SDK之外执行的操作。答案是“你做不到”的可能性很大。
答案 1 :(得分:1)
如何更改这些按钮的行为?
行为?你不能改变位于kindle fire底部的第三方应用程序按钮的行为(它只是OptionsMenu,并通过按其他基于Android的设备上的“菜单”按钮调用)
您可以停用这些按钮 - 主页,后退和其他内容......(但不是点燃)
Kindle Fire不支持包含disable_keyguard权限的应用或自定义锁屏。
答案 2 :(得分:1)
这里是:(java)
package com.wali.jackonsoptionsmenu;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
public class JacksonsOptionsMenuActivity extends Activity {
private final static String TAG = JacksonsOptionsMenuActivity.class
.getSimpleName();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
// this one is called once before showing OptionsMenu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Log.d(TAG,
"onCreateOptionsMenu: called once, while creating options menu");
getMenuInflater().inflate(R.menu.jackonsmenu, menu); // this one
// inflates your
// xml based
// menu into
// memory and
// sets to menu,
// from
// 'R.menu.jacksonsmenu
// to 'menu'
return true; // if You want to handle bottom bar menu (OptionsMenu) you
// have to return 'true'
}
// this one is called everytime, but before showing the menu
// if You want to change button name, icon or other stuff, do it here
// its something like preparing
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
Log.d(TAG,
"onPrepareOptionsMenu: called everytime before showing the OptionsMenu");
return true;
}
// this one is called everytime, after the OptionsMenu is shown
// this one comes, if everything is ok in Your implementation, otherwise,
// nothing
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Log.d(TAG, "onMenuÖpened: called everytime after the OptionsMenu shown");
return true;
}
// this on is called when an item selected try item.getItemId()
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.d(TAG, "onOptionsItemSelected: called when an item selected");
switch (item.getItemId()) {
case R.id.menuRefreshAll:
Log.i(TAG, "onOptionsItemSelected: refreshing everything");
break;
case R.id.menuManageSources:
Log.i(TAG, "onOptionsItemSelected: managing sources");
break;
}
return true;
}
// this on is called everytime after the optionsmenu is disappeared
@Override
public void onOptionsMenuClosed(Menu menu) {
Log.d(TAG,
"onOptionsMenuClosed: called everytime after the OptionsMenu is disappeared");
Log.i(TAG, "Hey Jackson, I'm disappeared");
}
}
xml文件
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/itemStatus" android:title="@string/titleStatus"
android:icon="@android:drawable/ic_menu_edit"></item>
<item android:title="@string/titleTimeline" android:id="@+id/itemTimeline"
android:icon="@android:drawable/ic_menu_sort_by_size"></item>
<item android:id="@+id/itemPrefs" android:title="@string/titlePrefs"
android:icon="@android:drawable/ic_menu_preferences"></item>
<item android:icon="@android:drawable/ic_menu_delete"
android:title="@string/titlePurge" android:id="@+id/itemPurge"></item>
<item android:title="@string/titleRefresh" android:id="@+id/itemRefresh"
android:icon="@android:drawable/ic_menu_rotate"></item>
</menu>
有一些技巧: 如果您有多个具有相同OptionsMenu的活动: 1.使用OptionsMenu创建基本活动 2.在处理相同OptionsMenu
的其他活动上继承此基本活动结果: 多个活动的相同菜单
关心,Galymzhan Sh