ahmetunal
ahmetunal

Reputation: 3960

Android List doesn't slide down

I'm at the very beginning of Android.

While I've been playing around with the views, I've encountered this problem, googled a little bit but couldn't find anything. I've listed some rows(textviews) horizontally.(See the picture). My problem is I cannot slide down the list to see the elements below. For slide to work, should I add some library/function/xml value?

What am i missing?

This is part of my java code (i take the data from the db and put it on screen with a while loop)

LinearLayout l = (LinearLayout)findViewById(R.id.myList);
TextView t = new TextView( getApplicationContext() );
t.setText("some text");
t.setClickable(true);
l.addView(t, 250, 30);

and my xml

<?xml version="1.0" encoding="utf-8"?>

<TextView    
    android:layout_width="fill_parent"    
    android:layout_height="wrap_content"    
    android:text="Add"    
    />    
<EditText    
    android:id="@+id/title"    
    android:singleLine="true"    
    android:layout_width="fill_parent"    
    android:layout_height="wrap_content"    
    />
<EditText    
    android:id="@+id/body"    
    android:singleLine="true"    
    android:layout_width="fill_parent"    
    android:layout_height="wrap_content"    
    />
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/myList" 
    >
    <Button  
        android:id="@+id/ok"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="Ok -----------> "  
        /> 
    <Button  
        android:id="@+id/delete"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="Delete All"  
        /> 
</LinearLayout>

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<TextView
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:id="@+id/list" 
    />
</LinearLayout>

enter image description here

Upvotes: 0

Views: 386

Answers (2)

mc_fish
mc_fish

Reputation: 503

You need to use a ScrollView to get a scrollbar. http://developer.android.com/reference/android/widget/ScrollView.html

Upvotes: 0

mgv
mgv

Reputation: 8484

You are using a TextView to hold your list of strings.

You should use a ListView for your list. It will be scrollable by default.

Here you have a full sample of a ListView that holds a list of strings.

Upvotes: 1

Related Questions