I want to display only 5 rows in a ListView , and the rest of them should be scrollable . So I tried this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <EditText android:id="@+id/txtFilename" android:layout_width="375dp" android:layout_height="wrap_content" android:layout_margin="10dp" /> <ListView android:id="@+id/ListView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbarSize="2dp" android: /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/gray" android:padding="5dp" > <Button android:id="@+id/btnOk" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="OK"/> <Button android:id="@+id/btnCancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="CANCEL"/> </LinearLayout> </LinearLayout>
and in java code
public class MainActivity extends Activity { private ListView list1; private String array[] = { "Iphone", "Tutorials", "Gallery", "Android", "item 1", "item 2", "item3", "item 4" }; @SuppressWarnings("unchecked") @Override protected void onCreate(Bundle savedInstanceState) {
have an idea how to achieve it
user2295109
source share