0

リストビューで顧客名と国と矢印を見てください。アプリケーションのテキストビューに同じ効果を実装したいと思います。

リストビューで顧客名と国と矢印を見てください。アプリケーションのテキストビューに同じ効果を実装したいと思います。つまり、テキストは左側と右側の矢印マークに配置する必要があり、テキストビューに触れると、別の画面が表示されるはずです。

4

1 に答える 1

0

これは単一の TextView ではなく、1 つのリスト アイテム RelativeLayout または LinearLayout で、その中に 2 つの TextView があり、右側の矢印グラフィックの ImageView です。タッチを処理して別の画面に移動する ListActivity または ListFragment を使用します。

http://developer.android.com/reference/android/app/ListFragment.html

サイトに示されているように、コードは次のようになります。

<?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="wrap_content">

 <TextView android:id="@+id/name"
     android:textSize="16sp"
     android:textStyle="bold"
     android:alignParentLeft="true"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/country"
     android:textSize="16sp"
     android:alignParentLeft="true"
     android:layout_below="@+id/name"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

 <ImageView android:id="@+id/arrow"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:alignParentRight="true"/>

次に、それに応じて微調整します。

編集 - -

XML でビューを作成したら、次のようなクリック リスナーをアクティビティに追加できます。

LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout);
layout.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // Do your code here to switch to another view or activity
    }
});
于 2013-01-03T16:05:06.487 に答える