程式碼:
以下為監聽 OnItemClickListener 事件
//==============================
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
Log.i("==MainGo==", "進入 listView onItemClick 區段");
TextView tv = (TextView)view.findViewById(R.id.tv_list_type);
Log.i("==MainGo==", tv.getText().toString());
}
自定 listView 的 xml 檔:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/tv_show_text_list" >
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/str_list_type"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
android:layout_height="wrap_content"
android:text="@string/str_list_go"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/str_list_name"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
沒有留言 :
張貼留言