2012-03-21 6 views
0

私はlinearlayoutを使うと、私のボタンを除いてすべてが想定どおりに動作します。 relativelayoutは私のボタンが動かなくなるようにします

私は私のボタンrelativelayout使用

は...

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<Button android:id="@+id/plus" 
android:background="@drawable/selector" 
android:layout_width="fill_parent" 
android:layout_height="75dp" 
android:layout_alignParentBottom="true" 
/> 

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

</ListView> 



    <TextView android:id="@android:id/empty" android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:text="@string/helptxt1" 

    /> 


    </RelativeLayout> 

..

public void addListenerOnButton() { 

    final Context context = this; 

    button1 = (Button) findViewById(R.id.plus); 

    button1.setOnClickListener(new OnClickListener() { 

    // @Override 
     public void onClick(View arg0) { 


      createNote(); 
     // Intent intent = new Intent(context, QuoteEdit.class); 
      //   startActivity(intent); 

     } 

    }); 

} 


private void createNote() { 
Intent i = new Intent(this, QuoteEdit.class); 
startActivityForResult(i, ACTIVITY_CREATE); 

} 
+0

。リストビューは無期限に拡張でき、スクロールビュー内に配置することはできません。このため、おそらくリストビューの下にボタンを表示することはできません。 – Shellum

答えて

0

になってそのような下にあるだけ、それは動作を停止していることの後の最初のリストビューのエントリのために働きます相対レイアウトを使用すると、すべてのビュー/ボタンが同じ位置に配置されるため、上下に配置しない限り、ボタンは機能しません。

<Button 
    android:id="@+id/plus" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" /> 

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

か、あなたのボタンにのonClickを追加することができます:あなたのレイアウトでこれをやってみ

<Button 
    android:id="@+id/plus" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:onClick="myClickMethod" /> 

とあなたのコードで、私はあなたがこれを行うことができますかわからない

public void myClickMethod(View view) { 

     createNote(); 

} 
+0

そんなにうまくいきました。 – xaaam

関連する問題