0

嗨,我正在android中开发应用程序。我在coverflow视图中显示了一些工作正常的图像。在coverflow视图下面我需要在列表视图中显示一些数据。我是android新手,我不知道如何在coverflow视图下方显示列表视图。请帮助我,这是我的代码:

My XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.coverflow.Coverflow
        android:id="@+id/cover_flow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />


   <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" />  


</LinearLayout>

My Activity class:


public class NewspaperCoverFlowActivity extends Activity 
{
    /** Called when the activity is first created. */
    ListViewwithimageAdapter listadapter;
    ListView list;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);  

        Coverflow coverFlow;
        coverFlow = new Coverflow(this);

        coverFlow.setAdapter(new ImageAdapter(this));
        ImageAdapter coverImageAdapter =  new ImageAdapter(this);

        coverFlow.setAdapter(coverImageAdapter);          

        coverFlow.setGravity(Gravity.TOP);

        coverFlow.setSpacing(2);
        coverFlow.setSelection(1, true);
        coverFlow.setAnimationDuration(1500);   
//        setContentView(coverFlow);
        ListView list = (ListView)findViewById(R.id.list);
        listadapter = new ListViewwithimageAdapter(this);
        list.setAdapter(listadapter);



    }



    }
4

1 回答 1

0

创建一个将方向设置为垂直的 LinearLayout 并将其设置为您的内容视图。然后将 Cover 流视图和列表视图添加到布局中。

如果您在布局 xml 中执行此操作,它将是这样的(将“com.example.package”更改为您的 CoverFlow 所在的 pckage):

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

    <com.example.package.CoverFlow
        android:id="@+id/cover_flow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />


    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>
于 2012-12-12T07:49:44.187 回答