1

我的布局代码如下所示:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relRingtone"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> 
            <ListView
               android:focusable="false"
             android:id="@+id/list_notification"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"   
             android:choiceMode="singleChoice"
             android:layout_marginLeft="3dip" 
             android:textSize="2dp" />
             <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:paddingBottom="40dp" >

            <Button
                android:id="@+id/btn1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="40dp"
                android:background="@drawable/button"
                android:padding="5dp"
                android:text="Start Working"
                android:textColor="#FFF"
                android:textSize="20sp"
                android:textStyle="bold" />

            <Chronometer
                android:id="@+id/chronometer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/btn1"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:padding="5dp"
                android:text="Vehicle  Details"
                android:textColor="#FFF"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="gone" />

            <Button
                android:id="@+id/btn2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/chronometer"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:background="@drawable/button"
                android:padding="5dp"
                android:text="Take Leave"
                android:textColor="#FFF"
                android:textSize="20sp"
                android:textStyle="bold" />
        </RelativeLayout>
    </ScrollView>

     </RelativeLayout>

下面是我的java代码:

list_notification.setVisibility(View.VISIBLE);
        String s[] = new String[] { "Your leave request has been accepted",
                "test notification" };
        ArrayAdapter<String> adpt = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, s);
        list_notification.setAdapter(adpt);
        list_notification.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                Toast.makeText(getApplicationContext(),
                        "list item clicked", Toast.LENGTH_SHORT).show();
            }
        });`
4

2 回答 2

1

问题是布局,添加android:layout_below="@id/list_notification"

ScrollView 不会覆盖列表视图

<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_below="@id/list_notification"
        >
于 2013-08-14T03:54:12.250 回答
0

我认为这条线<ListView>可能是罪魁祸首:

android:focusable="false"

假设您的错误只是单击项目不执行任何操作。

您的 UI 可能还有一些其他问题……当您的列表高于屏幕时,将列表视图堆叠在滚动视图之上会产生问题。

于 2013-08-14T03:26:41.733 回答