日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

虚拟按键自己触发的java代码_在SystemUI添加虚拟按键

發(fā)布時間:2024/9/27 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 虚拟按键自己触发的java代码_在SystemUI添加虚拟按键 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我們想要在volume、back、menu同一排添加一個虛擬按鍵,并且觸發(fā)一個應(yīng)用;

1、首先我們要找到這些虛擬按鍵的位置:\frameworks\base\packages\SystemUI\res\layout-sw600dp\navigation_bar.xml

2、橫屏?xí)r,最左邊的RelativeLayout 中添加:

......

android:layout_height="match_parent"

android:layout_width="match_parent"

>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="left">

android:id="@+id/img_logo"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="left|center_vertical"

android:paddingLeft="5.0dip"

android:src="@drawable/img_logo"

systemui:glowBackground="@drawable/ic_sysbar_highlight"

android:contentDescription="@string/accessibility_recent"/>

......

豎屏?xí)r,最左邊的RelativeLayout 中添加:

......

android:layout_height="match_parent"

android:layout_width="match_parent"

android:visibility="gone"

android:paddingTop="0dp"

>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="left">

android:id="@+id/img_logo"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="left|center_vertical"

android:paddingLeft="5.0dip"

android:src="@drawable/img_logo"

systemui:glowBackground="@drawable/ic_sysbar_highlight"

android:contentDescription="@string/accessibility_recent"/>

......

3、添加java觸發(fā)代碼:\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\NavigationBarView.java

(1)? ......

import android.content.ComponentName;//add Await

(2) //add Await 返回圖標(biāo)

public View getImgLogo(){

return mCurrentView.findViewById(R.id.img_logo);

}

(3)添加觸發(fā)應(yīng)用:

public void setNavigationIconHints(int hints, boolean force) {

if (!force && hints == mNavigationIconHints) return;

final boolean backAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;

if ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0 && !backAlt) {

mTransitionListener.onBackAltCleared();

}

if (DEBUG) {

android.widget.Toast.makeText(mContext,

"Navigation icon hints = " + hints,

500).show();

}

mNavigationIconHints = hints;

((ImageView)getBackButton()).setImageDrawable(backAlt

? (mVertical ? mBackAltLandIcon : mBackAltIcon)

: (mVertical ? mBackLandIcon : mBackIcon));

((ImageView)getRecentsButton()).setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon);

//add Await

((ImageView)getImgLogo()).setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent mIntent = new Intent( );

mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

ComponentName comp = new ComponentName("com.xintu.navcity", "com.xintu.navcity.MainActivity");

mIntent.setComponent(comp);

mIntent.setAction("android.intent.action.VIEW");

mContext.startActivity(mIntent);

}

});

setDisabledFlags(mDisabledFlags, true);

}

總結(jié)

以上是生活随笔為你收集整理的虚拟按键自己触发的java代码_在SystemUI添加虚拟按键的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。