2016-09-30 3 views
0

ListViewの外にButtonがあり、ボタンをクリックしました(onClickListener)が機能していません。私はandroid:focus = "false"、android:descendantFocusability = "blocksDescendants"を試しましたが、正しく使用したかどうかは分かりません。全く役に立たなかった。私はアンドロイドの初心者です、私はそれを修正するのを助けてください。ありがとうございました。ListViewの外で定義されたボタンが動作しません

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:baselineAligned="false"> 

<Button 
    android:text="Button" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/b1"/> 

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

答えて

1

設定した内容はすべて正しいです。 layout_widthプロパティとlayout_heightプロパティを変更するだけです。ボタンがリストビューに戻っているかもしれません。だからそれが現れない理由です。 は、以下のようにXMLでリストビューの内容を変更してみてください:

<ListView 
    android:layout_width="150dp" 
    android:layout_height="150dp" 
    android:id="@+id/listView1"/> 

それが正しいかどうかの答えをチェックしてください。

+0

ボタンが表示されていますが、クリックが認識されません(onClickListenerが機能していません)。 – Shreesha

+0

その後、urのonclicklistenerコードを投稿してください。エラーがどこにあるのか分かります。 – EED

関連する問題