0
我試圖用抽屜和工具欄/動作欄設置一個活動,但即時通訊設置有一些問題。Android:我需要安裝抽屜「漢堡圖標」onClickListener嗎?
我main_activity.xml:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp」>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/main_tool_bar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/main_tool_bar"/>
</RelativeLayout>
<!--... the rest of my layout for the drawer...-->
我toolbar.xml:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/toolbar_color"/>
活動:
public class MainActivity extends ActionBarActivity {
private void setupToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.main_tool_bar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_white);
toolbar.setTitle(getResources().getString(R.string.to_sign));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.openDrawer(Gravity.LEFT);
}
});
setActionBarTextColor(Color.WHITE);
}
//........ more code not related with bar or drawer.........
}
我希望能夠改變背景顏色,文字顏色和圖標(導航漢堡,或任何其他圖標),而不使用X. ML配置(主題)。
據我所知,setSupportActionBar(toolbar)會爲我實現clickListener。但是,當我不指定偵聽器時,該按鈕根本不起作用(根本沒有動作)。
」有太多可能的答案,或者對於這種格式來說答案太好,請添加詳細信息以縮小答案集或隔離幾個段落中可以回答的問題。「 – Simas
@Simas,我只是更新我的問題。你是對的,當時有一個問題對每個人都更清楚。 – Bugdr0id