不同的Android设备偶尔会有不同的屏幕功能(例如在点燃火灾应用程序中屏幕底部的按钮)。 你怎么能改变这种按钮的行为? 做这样的事我找不到任何资源..

**编辑**

我发现我所谓的“底部按钮”更恰当地称为亚马逊的某些Kindle Fire文档中的Options Bar

**编辑**

考虑到两个答案都说这不可能的,我决定是时候举个例子了。 看起来我想要制作的菜单实际上是应用程序的一部分,但是有一个用于这些系统按钮的按钮监听器。 如何查找使用这些按钮的示例代码?

Pulse app screenshot kindle fire

===============>>#1 票数:2

你怎么能改变这种按钮的行为?

您询问有问题的设备的制造商如何修改他们在Android SDK之外做的事情。 答案是“你不能”的几率非常好。

===============>>#2 票数:1

你怎么能改变这种按钮的行为?

行为? 你不能改变位于kindle fire底部的第三方应用程序按钮的行为(它只是OptionsMenu,并通过按其他Android设备上的“菜单”按钮调用)

你可以禁用这些按钮 - Home,Back和其他东西......(但不是点燃)

Kindle Fire不支持包含disable_keyguard权限的应用程序或自定义锁屏。

https://developer.amazon.com/help/faq.html#KindleFire

===============>>#3 票数: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

  ask by Jacksonkr translate from so

未解决问题?本站智能推荐:

关注微信公众号