activity_main.xml
<include layout="@layout/title"/>
引用上章自定义标题栏
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<include layout="@layout/title"/>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
MainActivity.java
private String[] data = {"Apple","Banana","Apple","Banana","Apple","Banana","Apple","Banana","Apple","Banana"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//隐藏系统自带标题栏
ActionBar actionBar = getSupportActionBar();
if(actionBar!=null){
actionBar.hide();
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1,data);
ListView listView = findViewById(R.id.list_view);
listView.setAdapter(adapter);
}
当String[]中的数据足够的,超出屏幕即可滑动查看文章来源:https://www.toymoban.com/news/detail-800383.html
文章来源地址https://www.toymoban.com/news/detail-800383.html
到了这里,关于滚动菜单ListView的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!