-1

リストビューに問題があり、上部にボタンがあり、下部にリストビューがあるはずです。

ただし、アプリケーションを実行すると、リストビューがボタンを完全にカバーします。この問題の主な原因は何ですか?

編集 - 大きな画像で申し訳ありません。サイズを変更する方法がわかりません

ここに画像の説明を入力

ここに画像の説明を入力

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

<Button
    android:id="@+id/buttonList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:onClick="onClick"
    android:text="@string/buttonShow" />

<ListView
    android:id="@+id/listDays"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/buttonList"/>

</RelativeLayout>


public class SimpleListView extends ListActivity{

    String[] days;
    Button mButtonList;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mButtonList = (Button)findViewById(R.id.buttonList);
        //mButtonList.setOnClickListener(btnListener);

        //setContentView(R.layout.activity_list);

        ListView lstView = getListView();
        lstView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        days = getResources().getStringArray(R.array.daysArray);
        setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked, days));
        }
4

3 に答える 3

0

これを簡単に使用できます:

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

<LinearLayout
    android:id="@+id/tab2"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.1"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Button" />
</LinearLayout>

<LinearLayout
    android:id="@+id/tab3"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.9"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

于 2013-08-22T13:36:13.437 に答える
0

修正を希望する場合は、コードを提供する必要があります。xml レイアウトを提供してください。ただし、詳細な情報がなければ、xml レイアウトに問題がある可能性があります。おそらくあなたに適したレイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
>
<Button
    android:id="@+id/header_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
 />
 <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:dividerHeight="1dip"
        android:paddingLeft="1dp"
        android:layout_below="@id/header_button"
        />
</RelativeLayout>
于 2013-08-22T13:30:47.210 に答える
0

あなたのxmlコードはほぼ正しいように見えます

プロパティ visibility.gone をコードのどこかに設定していますか?

于 2013-08-22T13:50:53.073 に答える