今回は、ラビットホールをさらに下って行く方法がわかりません。このように、カスタムアダプターとボタンを備えたListViewを取得しました
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#f16b7f" />
<Button
android:id="@+id/describe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/describe"
android:focusable="false" />
</LinearLayout>
そのListViewがあるフラグメントでは次のようになります
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_rewards_list,
container, false);
ListView rewardsList = (ListView) view.findViewById(R.id.rewardsList);
context = getActivity().getApplicationContext();
rewardAdapter = new RewardAdapter(context, movies);
rewardsList.setAdapter(rewardAdapter);
rewardsList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
mListener.onRewardSelected(arg2);
}
});
return view;
}
私がやりたいことは、ユーザーがアダプターのボタンのみをクリックし、クリックしたときにのみ呼び出すことです
mListener.onRewardSelected(arg2);
そして、私は方法がわかりませんでした