这一次,我不知道 2 如何在兔子洞中走得更远。我得到了带有自定义适配器和按钮的 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 看起来像的 Fragment 上
@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);
我不知道怎么做