这不是一个单一的 TextView,而是一个列表项 RelativeLayout 或 LinearLayout,其中包含两个 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 视图,你就可以在你的 Activity 中添加一个这样的点击监听器:
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
}
});