私の Android アプリケーションには、フラグメント ビューとリスト ビューを備えたスライド メニューがあります。このフラグメントのアイテム クリック リスナーを追加したいと思います。フラグメントに使用したコードは次のとおりです。
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class LeftMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.leftmenu, container, false);
}
}
これは、メニュー レイアウトのコードです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2C323F" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:background="@drawable/blue_bg">
</TableLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/searchView1"
android:layout_centerHorizontal="true"
android:entries="@array/menu_array">
</ListView>
ここでmenu_array
は文字列リソースです。Fragmentのリストビューにonitem click listnerを追加したいです。これを行う方法 これは私にとって複雑です。
前もって感謝します!