大佬教程收集整理的这篇文章主要介绍了android – 使用没有TitleBar或ActionBar的导航栏,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道有可能这样做,而不使用这些东西.我想知道是怎么回事NsMenuAdapter模型使用一个标题,然后有这些功能
getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true);
其中显然是寻找一个动作栏.我尝试了几个没有工作的模型,我刚刚完成的大型模块位于这里How to Add icons adjacent to titles for Android Navigation Drawer(这与我以下的链接相关,该项目来自gitHub这里是https://github.com/gabrielemariotti/androiddev/tree/master/NavigationDrawer).现在的关键是,我正在使用一个自定义的布局(即相对布局与线性布局混合),我真的很失去了我的下一步应该是为了让这个工作.
Sidenote:当我的main_activity.xml(导航抽屉的实现)中只有ListView时,它正好像想象的那样滑出来.但是我不知道如何用数据填充它.我基本上需要3个标题,它们将具有可点击的导航元素,其中包含元素旁边的图标.
我转向这个模型,大部分我的见解如何通过相对布局http://gmariotti.blogspot.com/2013/05/creating-navigation-drawer.html这样做但是他们使用动作/标题栏,这是真正的扔给我一个循环.
使你的xml像这样:
<android.support.v4.widget.DrawerLayout xmlns:android="http://scheR_125_11845@as.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- This is how your main page will look,just 2 buttons --> <RelativeLayout android:layout_width="match_parent" android:layout_height="100dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:onClick="onLeft" android:text="left" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentright="true" android:onClick="onRight" android:text="right" /> </RelativeLayout> <!-- Left Drawer --> <RelativeLayout android:id="@+id/whatYouWanTinLeftDrawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" > <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:BACkground="@android:color/BACkground_dark" /> <!-- you can have many more widgets here like buttons or labels --> </RelativeLayout> <!-- Right Drawer --> <RelativeLayout android:id="@+id/whatYouWanTinRightDrawer" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_gravity="right" > <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:BACkground="@android:color/holo_green_light" /> <!-- you can have many more widgets here like buttons or labels --> </RelativeLayout> </android.support.v4.widget.DrawerLayout>
然后让你的活动如下所示:
public class MainActivity extends Activity { RelativeLayout leftRL; RelativeLayout rightRL; DrawerLayout drawerLayout; @Override protected void onCreate(Bundle savedInstanceStatE) { super.onCreate(savedInstanceStatE); // I'm removing the ActionBar. @R_874_10613@estWindowFeature(Window.FEATURE_NO_titlE); setContentView(R.layout.activity_main); leftRL = (RelativeLayout)findViewById(R.id.whatYouWanTinLeftDrawer); rightRL = (RelativeLayout)findViewById(R.id.whatYouWanTinRightDrawer); drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); } public void onLeft(View view) { drawerLayout.openDrawer(leftRL); } public void onRight(View view) { drawerLayout.openDrawer(rightRL); } }
而已.希望有帮助
以上是大佬教程为你收集整理的android – 使用没有TitleBar或ActionBar的导航栏全部内容,希望文章能够帮你解决android – 使用没有TitleBar或ActionBar的导航栏所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。