2017-03-03 13 views
0

私はAndroidの非常に始まりです。これは私の最初のプロジェクトです。私はリストビューを使ってEditTextTextViewを並べて表示しています。それは、以下のすべてのEditText instead.Theに表示されているButtonビューを使用していた場合今私はend.Butで送信ボタンをしたい私のXMLファイルです:ボタンの位置合わせ

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
<TextView 
    android:id="@+id/txtview" 
    android:text="subject" 
    android:layout_width="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:paddingLeft="10dp" 
    android:textSize="25dp" 
    android:textColor="@color/black" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.7" 
    android:paddingRight="20dp" 
    android:textStyle="bold" 
    /> 
<EditText 
    android:cursorVisible="true" 
    android:id="@+id/ScanText" 
    android:hint="Internal+External" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.3" 
    android:layout_toRightOf="@id/textView" 
    android:inputType="number" 
    android:layout_marginTop="20dp" 
    /> 
<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Submit" 
    android:layout_alignParentEnd="true" 
    android:id="@+id/submitbutton"/> 
</RelativeLayout> 

これはListView用途にadapterレイアウトです。私はbottom.Iで単一のボタンは、私が一番下

this is the output i got

で唯一の送信ボタンを必要とするbelow.Butとして出力を持って表示する方法 TextView s.Soがあるのでボタンも何回も表示されています

私はバット私main activityListView以下で、それは以下のwork.The did'nt .Butにすることは、私のXMLです:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 

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

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Submit" 

    android:id="@+id/submitbutton"/> 


</LinearLayout> 
+0

は、あなたの期待される出力を示して! –

+4

このレイアウトからボタンを削除すると、このレイアウトはリスト項目用です。 listViewが含まれているレイアウトにボタンを追加します。 –

+2

ボタンをあなたの活動レイアウトに入れてください。 - 毎回ボタンを作成したくない場合は – rafsanahmad007

答えて

0

あなたはそれを変更しようとすることができます:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 

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

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Submit" 

     android:id="@+id/submitbutton"/> 


    </LinearLayout> 

(なぜならmatch_parentでwrap_contentにlayout_heightを変更しますあなたのボタンの場所はこれ以上ありません)

私はこれもやってみてください。

それが動作しない場合は、この行を追加しよう:

android:layout_weight="1" 

あなたのListViewへ

+0

@dupuisは動作しません –

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

     <ListView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/list" 
      android:layout_weight="1"/> 

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

</LinearLayout> 
+0

は魔法のように機能しました!ありがとうdhanvani –

+0

ようこそ、あなたも私に投票することができます。 @kishoreKumar –