how to add multiple listview in scrollview
how to ad multiple listview in scroll view ihave code which suppport
single listview which is scrolling how do i add multiple listview? below
is my code which support scroll single listview how do i add multiple
listview???
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>
No comments:
Post a Comment