这一次我没有说明如何进一步深入兔洞。 我得到了带有自定义适配器和按钮的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>
在Fragment上,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);
我不知道如何
答案 0 :(得分:2)
这个线程似乎处理了同样的问题并找到了解决方案?