2012-01-25 12 views
-1

自分のアクティビティのレイアウトを設定するのが難しいです。私はリストの各行がアイコンを含むリストレイアウトと、各アイコンの隣に2つのEditTextビューを達成しようとしています。Androidのレイアウト:行ごとに1つの画像と2つのEditTextビュー

たとえば、Gmailのアイコンをクリックすると、ユーザーは自分のメールとパスワードをビューに入力できます。

私はいくつかのアプローチを試してきましたが、1つは機能していないようです。一番近いのは、行ごとに1つのEditTextビューですが、これは私が達成しようとしているものではありません。

ここで私のXMLを見ています。誰かが私がどのように改善できるかについての提案があればそれはすばらしいだろう。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5dp" > 
    <RelativeLayout > 
     <ImageView 
      android:id="@+id/logo" 

      android:layout_width="150px" 
      android:layout_height="150px" 

      android:layout_alignParentTop="true" 
      android:layout_alignParentBottom="true" 

      android:src="@drawable/gm" > 
     </ImageView> 
     <EditText 
      android:id="@+id/secondLine" 
      android:layout_width="200dp" 
      android:layout_height="wrap_content" 

      android:layout_alignRight="@id/logo" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      > 
     </EditText> 
     <EditText 
      android:id="@+id/firstLine" 
      android:layout_width="200dp" 
      android:layout_height="wrap_content" 
      android:layout_alignRight="@id/logo" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:layout_above="@id/secondLine"> 
     </EditText> 
    </RelativeLayout> 
</LinearLayout> 
+2

あなたは記事[レイアウトトリック:効率的なレイアウトの作成]見たことがあります(http://developer.android.com/resources/articles/layout-tricks-efficiency.htmlを)。それはあなたがしようとしているものと全く同じように聞こえる例を持っています。 –

答えて

1

あなたはレイアウトをもっと読まなければなりません。親の上と下に画像を設定しています。それは完全に意味をなさない。これがリストビューのアイテム行であれば、これに変更します。

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

<RelativeLayout 
android:orientation="horizontal" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

<ImageView 
    android:id="@+id/logo" 
    android:layout_width="150px" 
    android:layout_height="150px" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:src="@drawable/gm" > 
</ImageView> 

<EditText 
    android:id="@+id/firstLine" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:layout_alignRight="@id/logo" 
    > 
</EditText> 

<EditText 
    android:id="@+id/secondLine" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:layout_alignRight="@id/logo" 
    android:layout_alignParentRight="true" 
    android:layout_alignRight="@id/firstLine" 
    > 
</EditText> 

+0

これはうまくいきました。確かに、私が忘れてしまったレイアウトを読む必要があります。 – Jnanathan

0

listviewを使用し、カスタム行を含むカスタムアダプタを作成します。

関連する問題