SidingMenu bố trí:
Bạn nên đặt ListView
như bố trí menu.Tiếp theo, tạo sliding_menu_header.xml
bố trí với ImageView
và TextView
bên:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:src="@drawable/image_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Bây giờ, bạn có thể thổi phồng bố trí này và thiết lập nó như ListView
's xem tiêu đề: bố trí
View menuHeader = getLayoutInflater().inflate(R.layout.sliding_menu_header, null);
mListView.addHeaderView(menuHeader);
mListView.setAdapter(mYourMenuAdapter);
ActionBar:
Bạn có thể thêm chế độ xem tùy chỉnh vào ActionBar
. Trong trường hợp của bạn bố trí có thể như:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:text="button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/button2"
android:text="button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Sau đó thêm bên dưới dòng để phương pháp onCreate
của bạn:
ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.actionbar_view);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_SHOW_HOME);
Button button1 = actionBar.getCustomView.findViewById(R.id.button1);
Button button2 = actionBar.getCustomView.findViewById(R.id.button2);
Hy vọng nó sẽ rất hữu ích cho bạn. Nếu câu trả lời của tôi chưa đầy đủ, hãy bình luận và tôi sẽ cập nhật nó.
@Gaston F. nó có hoạt động không? xin vui lòng chấp nhận câu trả lời của tôi nếu tôi giúp bạn – Aspicas
cảm ơn các liên kết của bạn, tôi đã thấy thông tin đó, những thư viện và ví dụ mà tôi đã cài đặt nhưng tôi không thể thực hiện screen2 (với khả năng tưởng tượng qua liên kết) và tôi không thể thêm button1 và button2 trên thanh trên cùng (xem hình ảnh cuối cùng). Nếu bạn có một giải pháp, xin vui lòng tôi đánh giá cao sự giúp đỡ. Cảm ơn –
Bạn có muốn các nút như "tab" hoặc chỉ các nút có một biểu tượng không? – Aspicas