如何在滚动视图中添加多个列表视图 我有支持滚动的单个列表视图的代码 如何添加多个列表视图?下面是我支持滚动单个列表视图的代码我如何添加多个列表视图???
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView = (ListView) findViewById(R.id.lisview);
View headerView = LayoutInflater.from(this).inflate(R.layout.header, null);
listView.addHeaderView(headerView);
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i<100; i++){
list.add(String.valueOf(i));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, list);
listView.setAdapter(adapter);
}
<!--activity_main.xml--->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res
/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textSize="30sp"
android:layout_gravity="center"/>
</FrameLayout>
<ListView
android:id="@+id/lisview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="#00000000"/>
</LinearLayout>
<!-----header.xnml---->
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Header View"
android:textSize="30sp"
android:textColor="#ff00ff00"
android:layout_gravity="center"/>
</FrameLayout>