Android的ListActivity滚动型如何获得一个列表中滚动 [英] Android ListActivity Scrollview How to get a list to scroll

查看:163
本文介绍了Android的ListActivity滚动型如何获得一个列表中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在经历一个教程 http://www.vogella.de/articles /AndroidListView/article.html
学习如何做使用ListActivity。我试图让在列表中滚动,但来到意识到,你不能使用滚动视图在布局文件来做到这一点。围绕谷歌搜索后,我意识到,android的不允许,但我一直没能找到,这似乎解释了如何使滚动发生一个答案。

I was going through a tutorial on http://www.vogella.de/articles/AndroidListView/article.html learning how to do use ListActivity. I am trying to get the list to scroll, but came to realize that you can't use scrollview in the layout file to make this happen. After googling around, I realized that android doesn't allow this, but I haven't been able to find an answer that seems to explain how to make the scrolling happen.

在code是如下:

public class MyListActivityActivity extends ListActivity {
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
    String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2" , "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2"  };
    /*LayoutInflater factory = getLayoutInflater();
    LinearLayout footer = 
            (LinearLayout) factory.inflate(R.layout.main, null);
     getListView().addFooterView(footer); */


    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            R.layout.rowlayout, R.id.label, values);
    setListAdapter(adapter);
}

    protected void onListItemClick(ListView l, View v, int position, long id) {
    String item = (String) getListAdapter().getItem(position);
    Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
}

//的XML文件:
    

//The xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
    android:id="@+id/icon"
    android:layout_width="22px"
    android:layout_height="22px"
    android:layout_marginLeft="4px"
    android:layout_marginRight="10px"
    android:layout_marginTop="4px"
    android:src="@drawable/ic_launcher" >
</ImageView>

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@+id/label"
    android:textSize="20px" >
</TextView>

</LinearLayout>

目前,您放入数组的多个值,较小的列表成为以确保它适合在屏幕上。我希望文本保持相同的大小,让它成为一个长长的清单,我可以滚动查看。

Currently, the more values you put into the array, the smaller the list becomes to make sure that it fits on the screen. I want the text to stay the same size and let it be a long list that I could scroll through.

我在什么地方的addHeader左右和addFooter那将会使滚动发生读取。但是,任何人都可以向我解释或使我有关于如何实现这一信息的来源?

I've read somewhere about addHeader and addFooter that'd enable the scrolling to happen. But can anyone explain to me or lead me to a source that has more information about how to implement this?

我倒是AP preciate任何输入。谢谢

I'd appreciate any input. Thanks

推荐答案

的ListView 本身就是一个滚动窗口小部件,所以它不能的内部使用滚动型

the ListView is itself a scrolling widget, so it can't be used inside of a ScrollView

这篇关于Android的ListActivity滚动型如何获得一个列表中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆